From 5fe707ea72cf1f62ab43ee79e6def1bb67f3e327 Mon Sep 17 00:00:00 2001 From: Raghav-Sudhakar Date: Mon, 7 Nov 2022 19:20:57 +0530 Subject: [PATCH 1/9] WF-64663-Updated README.md file. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e2379d..3621c01 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # How-to-select-the-item-through-index-in-WF-SfComboBox -This respository contains the sample that how to select the item through index in WF SfComboBox control. +This respository contains the sample that how to select the item through index in WF SfComboBox control. 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). From 4450284679e61697727217dc0d09b2d1d539c1e9 Mon Sep 17 00:00:00 2001 From: Raghav-Sudhakar Date: Mon, 14 Nov 2022 18:03:06 +0530 Subject: [PATCH 2/9] WF-64663-Updated Content and Images. --- README.md | 4 +++- .../Image/Select item through index.png | Bin 2 files changed, 3 insertions(+), 1 deletion(-) rename output.png => SfComboBox_Selection_C#/Image/Select item through index.png (100%) diff --git a/README.md b/README.md index 3621c01..1745063 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # How-to-select-the-item-through-index-in-WF-SfComboBox -This respository contains the sample that how to select the item through index in WF SfComboBox control. 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). +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). + +![Select Item through Index](SfComboBox_Selection_C#/Image/Select%20item%20through%20index.png) diff --git a/output.png b/SfComboBox_Selection_C#/Image/Select item through index.png similarity index 100% rename from output.png rename to SfComboBox_Selection_C#/Image/Select item through index.png From 746140447d1eea45d45ba784dbad0d0b82dfb771 Mon Sep 17 00:00:00 2001 From: Raghav-Sudhakar <93652178+Raghav-Sudhakar@users.noreply.github.com> Date: Tue, 29 Nov 2022 13:04:15 +0530 Subject: [PATCH 3/9] Update README.md --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 1745063..39a6f63 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,31 @@ # How-to-select-the-item-through-index-in-WF-SfComboBox 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). +# C# + public Form1() + { + InitializeComponent(); + List list = GetData(); + SfComboBox sfComboBox1 = new SfComboBox(); + sfComboBox1.Size = new Size(150, 28); + sfComboBox1.Location = new Point(138, 56); + sfComboBox1.DataSource = list; + + //Bind the Display member and Value member to the data source + sfComboBox1.DisplayMember = "DispValue"; + sfComboBox1.ValueMember = "SfValue"; + sfComboBox1.ComboBoxMode = Syncfusion.WinForms.ListView.Enums.ComboBoxMode.SingleSelection; + sfComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; + sfComboBox1.AutoCompleteSuggestMode = Syncfusion.WinForms.ListView.Enums.AutoCompleteSuggestMode.Contains; + sfComboBox1.MaxDropDownItems = 10; + + //Select the item based on index + sfComboBox1.SelectedIndex = list[1].SfValue; + + //Select the item based on item + sfComboBox1.SelectedItem = list[1]; + this.Controls.Add(sfComboBox1); + } + + ![Select Item through Index](SfComboBox_Selection_C#/Image/Select%20item%20through%20index.png) From 367d2f557d38174717e09cf7bdeddc3524e0c775 Mon Sep 17 00:00:00 2001 From: Raghav-Sudhakar <93652178+Raghav-Sudhakar@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:09:09 +0530 Subject: [PATCH 4/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39a6f63..f22b3d5 100644 --- a/README.md +++ b/README.md @@ -27,5 +27,5 @@ Index of the selected item can be retrieved by using the SelectedIndex property. this.Controls.Add(sfComboBox1); } +![Select Index programatically](https://user-images.githubusercontent.com/93652178/204493571-d426dda0-9da9-4d63-aa24-50e99dd292f3.png) -![Select Item through Index](SfComboBox_Selection_C#/Image/Select%20item%20through%20index.png) From 9a0f5bdc70fa174e8bdac05608023a800988f3ef Mon Sep 17 00:00:00 2001 From: Raghav-Sudhakar <93652178+Raghav-Sudhakar@users.noreply.github.com> Date: Tue, 29 Nov 2022 16:14:54 +0530 Subject: [PATCH 5/9] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f22b3d5..074195c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ 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). # C# + public Form1() { InitializeComponent(); From 241e2c5ee2e12ccf9e72878b3011e87fe639e857 Mon Sep 17 00:00:00 2001 From: SyncfusionBuild <89958145+SyncfusionBuild@users.noreply.github.com> Date: Tue, 24 Jan 2023 16:21:05 +0530 Subject: [PATCH 6/9] Gitleaks action file added --- .github/workflows/gitleaks.yaml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/gitleaks.yaml diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..48a24dd --- /dev/null +++ b/.github/workflows/gitleaks.yaml @@ -0,0 +1,38 @@ +name: Secret Value found! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v1 + with: + nuget-version: latest + - name: Install the dotnet + if: steps.gitleaks.outcome != 'success' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '3.1.x' + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" + dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "citeam@syncfusion.com" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" + exit 1 From b469b76cf27994edc2290fd37c29efc562cb53f7 Mon Sep 17 00:00:00 2001 From: Manivannan-E <92844213+Manivannan-E@users.noreply.github.com> Date: Tue, 25 Nov 2025 09:48:49 +0530 Subject: [PATCH 7/9] Update README.md --- README.md | 103 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 074195c..0c7522b 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,73 @@ -# How-to-select-the-item-through-index-in-WF-SfComboBox -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). - -# C# - - public Form1() - { - InitializeComponent(); - List list = GetData(); - SfComboBox sfComboBox1 = new SfComboBox(); - sfComboBox1.Size = new Size(150, 28); - sfComboBox1.Location = new Point(138, 56); - sfComboBox1.DataSource = list; - - //Bind the Display member and Value member to the data source - sfComboBox1.DisplayMember = "DispValue"; - sfComboBox1.ValueMember = "SfValue"; - sfComboBox1.ComboBoxMode = Syncfusion.WinForms.ListView.Enums.ComboBoxMode.SingleSelection; - sfComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; - sfComboBox1.AutoCompleteSuggestMode = Syncfusion.WinForms.ListView.Enums.AutoCompleteSuggestMode.Contains; - sfComboBox1.MaxDropDownItems = 10; - - //Select the item based on index - sfComboBox1.SelectedIndex = list[1].SfValue; - - //Select the item based on item - sfComboBox1.SelectedItem = list[1]; - this.Controls.Add(sfComboBox1); - } - -![Select Index programatically](https://user-images.githubusercontent.com/93652178/204493571-d426dda0-9da9-4d63-aa24-50e99dd292f3.png) +# How to Select an Item by Index in WinForms SfComboBox +This example demonstrates how to select an item programmatically by index in the Syncfusion WinForms SfComboBox control. The SfComboBox supports both index-based selection and object-based selection, making it flexible for scenarios like applying default selections, loading saved preferences, or responding to application logic. + +## Why This Is Useful +- **Dynamic Selection**: Automatically select items based on conditions. +- **Improved UX**: Pre-load user preferences or defaults. +- **Flexibility**: Choose items by index or by object reference. + +## Key Properties +- **SelectedIndex**: Sets or gets the zero-based index of the selected item. +- **SelectedItem**: Sets or gets the actual object from the data source. + +## Example Code +```C# + +public Form1() +{ + InitializeComponent(); + + // Sample data + List list = GetData(); + + // Create and configure SfComboBox + SfComboBox sfComboBox1 = new SfComboBox + { + Size = new Size(150, 28), + Location = new Point(138, 56), + DataSource = list, + DisplayMember = "DispValue", + ValueMember = "SfValue", + ComboBoxMode = Syncfusion.WinForms.ListView.Enums.ComboBoxMode.SingleSelection, + AutoCompleteMode = AutoCompleteMode.SuggestAppend, + AutoCompleteSuggestMode = Syncfusion.WinForms.ListView.Enums.AutoCompleteSuggestMode.Contains, + MaxDropDownItems = 10 + }; + + // Select the item based on index (second item) + sfComboBox1.SelectedIndex = 1; + + // Select the item based on object + sfComboBox1.SelectedItem = list[1]; + + this.Controls.Add(sfComboBox1); +} + +private List GetData() +{ + return new List + { + new State { DispValue = "California", SfValue = 1 }, + new State { DispValue = "Texas", SfValue = 2 }, + new State { DispValue = "Florida", SfValue = 3 } + }; +} + +public class State +{ + public string DispValue { get; set; } + public int SfValue { get; set; } +} +``` + +## Notes +- Use SelectedIndex for index-based selection (zero-based). +- Use SelectedItem for object-based selection. +- Ensure the data source is bound before setting these properties. + +## Reference +For more details, refer to the official Syncfusion Knowledge Base: https://support.syncfusion.com/kb/article/10653/how-to-select-the-item-through-index-in-winforms-sfcombobox + +## Output +![Select item through index in WinForms SfComboBox](output.png) From 6ae87b32ca682cafac56bc024236b3f8e1b28783 Mon Sep 17 00:00:00 2001 From: Manivannan Date: Tue, 25 Nov 2025 09:53:08 +0530 Subject: [PATCH 8/9] Added image. --- .github/workflows/gitleaks.yaml | 10 +++++----- ...ng => index_selection_in_winforms_sfcombobox.png | Bin 2 files changed, 5 insertions(+), 5 deletions(-) rename SfComboBox_Selection_C#/Image/Select item through index.png => index_selection_in_winforms_sfcombobox.png (100%) diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 48a24dd..c115f77 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -1,4 +1,4 @@ -name: Secret Value found! +name: Secret Value found!! on: push: public: @@ -32,7 +32,7 @@ jobs: - name: Install the report tool packages if: steps.gitleaks.outcome != 'success' run: | - nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" - dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1 - dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "citeam@syncfusion.com" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" - exit 1 + nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion + dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }} + exit 1 \ No newline at end of file diff --git a/SfComboBox_Selection_C#/Image/Select item through index.png b/index_selection_in_winforms_sfcombobox.png similarity index 100% rename from SfComboBox_Selection_C#/Image/Select item through index.png rename to index_selection_in_winforms_sfcombobox.png From 6d2f9c98c86093a0e75d99702f021edd057ee1b3 Mon Sep 17 00:00:00 2001 From: Manivannan-E <92844213+Manivannan-E@users.noreply.github.com> Date: Tue, 25 Nov 2025 09:54:15 +0530 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c7522b..0055751 100644 --- a/README.md +++ b/README.md @@ -69,5 +69,5 @@ public class State For more details, refer to the official Syncfusion Knowledge Base: https://support.syncfusion.com/kb/article/10653/how-to-select-the-item-through-index-in-winforms-sfcombobox ## Output -![Select item through index in WinForms SfComboBox](output.png) +![Select item through index in WinForms SfComboBox](index_selection_in_winforms_sfcombobox.png)