From 76c00c1436a3c8e28e8f38e925ee900d3d401056 Mon Sep 17 00:00:00 2001 From: KrithikaGanesan Date: Mon, 27 Oct 2025 17:52:24 +0530 Subject: [PATCH 1/2] 985360: Updated ReadMe file of this repository --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66cb6a9..c9526a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,41 @@ -# How-to-filter-the-dropdown-items-in-Winforms-SfComboBox -This respository contains the sample that how to filter the dropdown items by setting the Filter property of DropDownListView in WF SfComboBox control. +# How to Filter the Dropdown Items in WinForms SfComboBox +This repository demonstrates how to filter items in the Syncfusion WinForms SfComboBox control using the built-in filtering feature. The SfComboBox is a modern replacement for the standard ComboBox, offering advanced features such as data binding, auto-complete, and customizable filtering logic. Filtering allows you to display only relevant items based on user-defined conditions, improving usability and performance in applications with large datasets. -UG link: https://help.syncfusion.com/windowsforms/combobox/filtering \ No newline at end of file +## Key Features Demonstrated in This Sample + • Apply custom filtering logic using the Filter property of DropDownListView. + • Refresh the filter dynamically at runtime. + • Use predicates to determine which items should be visible in the dropdown. + +## How Filtering Works +The Filter property accepts a predicate that is evaluated for each item in the data source. If the predicate returns true, the item remains visible; otherwise, it is hidden. This approach provides flexibility to implement complex filtering scenarios such as prefix matching, substring search, or conditional visibility based on multiple fields. + +## Example Code (C#) +```csharp +public Form1() +{ + InitializeComponent(); + + List list = GetData(); + this.sfComboBox1.DataSource = list; + this.sfComboBox1.DisplayMember = "LongName"; + this.sfComboBox1.ThemeName = "Office2016Colorful"; + this.sfComboBox1.DropDownListView.Style.ItemStyle.Font = new Font("Microsoft Sans Serif", 9.75f); + + // Apply filter + sfComboBox1.DropDownListView.View.Filter = FilterItem; + sfComboBox1.DropDownListView.View.RefreshFilter(); +} + +// Filter predicate +private bool FilterItem(object data) +{ + if ((data as USState).LongName.StartsWith("C")) + return true; + return false; +} +``` + +This sample filters the dropdown items so that only states starting with the letter C are displayed. You can modify the predicate to implement custom logic such as filtering by length, region, or any other property. + +For more details, refer to the official UG documentation: +🔗 [Filtering in Windows Forms ComboBox](https://help.syncfusion.com/windowsforms/combobox/filtering) \ No newline at end of file From a1b4ce9e0ec0d9002c27f308d23f4d076c211b44 Mon Sep 17 00:00:00 2001 From: KrithikaGanesan Date: Mon, 27 Oct 2025 17:53:34 +0530 Subject: [PATCH 2/2] 985360: Updated ReadMe file of this repository --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9526a3..13b7b74 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ private bool FilterItem(object data) This sample filters the dropdown items so that only states starting with the letter C are displayed. You can modify the predicate to implement custom logic such as filtering by length, region, or any other property. For more details, refer to the official UG documentation: -🔗 [Filtering in Windows Forms ComboBox](https://help.syncfusion.com/windowsforms/combobox/filtering) \ No newline at end of file +🔗 [Filtering in Windows Forms SfComboBox](https://help.syncfusion.com/windowsforms/combobox/filtering) \ No newline at end of file