Skip to content

SyncfusionExamples/How-to-select-a-Row-by-Cell-Value-in-WinForms-SfDataGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to select a Row by Cell Value in WinForms DataGrid?

In a WinForms DataGrid (SfDataGrid), a row can be selected based on a specific cell value. A TextBox has been implemented to allow users to enter the desired cell value. If the entered value matches any value within the DataGrid columns, the corresponding row is retrieved and set as the SelectedItem.

private void SelectRow(object sender, EventArgs e)
{
    // Retrive the data based on entered cell value.
    var rowData = orderInfoCollection.Orders.FirstOrDefault(data => 
                  data.OrderID.ToString().ToLower() == textBox1.Text.ToLower() ||
                  data.CustomerID.ToString().ToLower() == textBox1.Text.ToLower() ||
                  data.CustomerName.ToString().ToLower() == textBox1.Text.ToLower() ||
                  data.ShipCity.ToString().ToLower() == textBox1.Text.ToLower() ||
                  data.Country.ToString().ToLower() == textBox1.Text.ToLower());

    // Select the retrived data
    this.sfDataGrid1.SelectedItem = rowData;
}

Select a row by cellvalue

Take a moment to peruse the WinForms DataGrid - Selection documentation, to learn more about DataGrid Selections with examples.

About

This demo shows how to select a Row by Cell Value in WinForms SfDataGrid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages