We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Search value on specific column

Hi (Sorry my bad english)


I am trying to create a search to locate a specific element on a single column using the sfDataGrid control since I am migrating a project from the old datagridboundgrid control, which changes a lot in its syntax, how can I perform such a search


Thanks in advanced


3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team October 27, 2022 04:21 PM UTC

Hi ERH,

Your requirement to search value on a specific column in SfDataGrid can be achieved by using the SearchColumns collection. Please refer to the below code snippet,

private void OnTextChanged(object sender, EventArgs e)

{

    // Search only in Country column

    this.sfDataGrid.SearchController.SearchColumns.Add("Country");

   

    this.sfDataGrid.SearchController.Search(this.txtSearchBox.Text);

}            


UG Link: https://help.syncfusion.com/windowsforms/datagrid/search#search-only-in-selected-columns


Please find the sample in the attachment and let us know if you have any concerns about this.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: SfDataGridDemo_c2b21516.zip

Marked as answer

ER ERH October 27, 2022 05:40 PM UTC

Thanks a lot

One more question, there is a hand book , where you can see the events of the control, for example I want to identify when the user moves from row, or cell, to identify which one he moved on




VS Vijayarasan Sivanandham Syncfusion Team October 28, 2022 04:03 PM UTC

Hi ERH,
We suspect that your requirement is to select move from one row to another and identify the selected row using the event in SfDataGrid. You can achieve this by using the SelectionChanging and SelectionChanged events. Please refer to the below code snippet,


//Event subscription

sfDataGrid.SelectionChanging += OnSelectionChanging;

sfDataGrid.SelectionChanged += OnSelectionChanged;

 

//Event customization

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)

{

    //Here customize based on your scenario

}

 

//Event customization

private void OnSelectionChanging(object sender, SelectionChangingEventArgs e)

{

    //Here customize based on your scenario

}


UG Link: https://help.syncfusion.com/windowsforms/datagrid/selection#retrieving-the-current-item-and-display-in-message-box

https://help.syncfusion.com/windowsforms/datagrid/selection#cancel-selection

Please find the sample in the attachment and let us know if you have any concerns about this.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_41b0ce23.zip

Loader.
Live Chat Icon For mobile
Up arrow icon