How to search particular value in WinForms GridGrouping?
Search the value in combo dropdown
In the WinForms GridGrouping, you can set the current item based on the specified value by using the KeyDown event. You can identify the RowIndex by using the Find method of the DataView. By using this RowIndex, the respective row can be selected by adding the particular record into the SelectedRecords of grid.
C#
this.comboDropDown1.TextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown); void TextBox_KeyDown(object sender, KeyEventArgs e) { if(e.KeyData == Keys.Enter) { DataView dataView = dt.DefaultView; dataView.Sort = "ProductName"; int row = dataView.Find(this.comboDropDown1.Text); if(row != -1) { //Removes the previous selections this.gridGroupingControl1.Table.SelectedRecords.Clear(); //Adds the record to the SelectedRecords collection this.gridGroupingControl1.Table.SelectedRecords.Add(this.gridGroupingControl1.Table.Records[row]); } } }
VB
AddHandler comboDropDown1.TextBox.KeyDown, AddressOf TextBox_KeyDown Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) If e.KeyData = Keys.Enter Then Dim dataView As DataView = dt.DefaultView dataView.Sort = "ProductName" Dim row As Integer = dataView.Find(Me.comboDropDown1.Text) If row <> -1 Then 'Removes the previous selections Me.gridGroupingControl1.Table.SelectedRecords.Clear() 'Adds the record to the SelectedRecords collection Me.gridGroupingControl1.Table.SelectedRecords.Add(Me.gridGroupingControl1.Table.Records(row)) End If End If End Sub
The following screenshot displays how to set the current item based on the specified value.
Samples:
C#: ComboBox
VB: ComboBox
Conclusion
I hope you enjoyed learning about how to search particular value in WinForms GridGrouping.
You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!