Skip to content

Commit 7461404

Browse files
Update README.md
1 parent 4450284 commit 7461404

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
# How-to-select-the-item-through-index-in-WF-SfComboBox
22
Index of the selected item can be retrieved by using the SelectedIndex property. For more details please refer [How to select the item thorugh index index in SfComboBox](https://www.syncfusion.com/kb/12171/how-to-select-the-item-through-index-in-winforms-sfcombobox).
33

4+
# C#
5+
public Form1()
6+
{
7+
InitializeComponent();
8+
List<State> list = GetData();
9+
SfComboBox sfComboBox1 = new SfComboBox();
10+
sfComboBox1.Size = new Size(150, 28);
11+
sfComboBox1.Location = new Point(138, 56);
12+
sfComboBox1.DataSource = list;
13+
14+
//Bind the Display member and Value member to the data source
15+
sfComboBox1.DisplayMember = "DispValue";
16+
sfComboBox1.ValueMember = "SfValue";
17+
sfComboBox1.ComboBoxMode = Syncfusion.WinForms.ListView.Enums.ComboBoxMode.SingleSelection;
18+
sfComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
19+
sfComboBox1.AutoCompleteSuggestMode = Syncfusion.WinForms.ListView.Enums.AutoCompleteSuggestMode.Contains;
20+
sfComboBox1.MaxDropDownItems = 10;
21+
22+
//Select the item based on index
23+
sfComboBox1.SelectedIndex = list[1].SfValue;
24+
25+
//Select the item based on item
26+
sfComboBox1.SelectedItem = list[1];
27+
this.Controls.Add(sfComboBox1);
28+
}
29+
30+
431
![Select Item through Index](SfComboBox_Selection_C#/Image/Select%20item%20through%20index.png)

0 commit comments

Comments
 (0)