DataGridView for Windows Forms Create data gird view in C# with modern user interface for your Windows Forms applications Iterating Rows in C# DataGridView
The Kettic DataGridView Component has the ability to iterate through data grid rows while applying the grouping feature, or show total rows which have result values calculated from the functions like Sum, Count, Min, Max, Average, etc. Whatâs more, these results can be completely customized as necessary. Iterate through Grid Rows in C#
The C# DataGridView allows users of it to iterate via data grid rows by using the objects, Rows collection of GridViewRowInformation. We are going through selecting the last row and then iterating looking for grid rows chosen with the sample as below. The GridViewRowInformation BeVisiable() method will scroll the grid rows after the rows selected to be found.
C# Code for Iterating through Grid Rows GridViewRowInformation lastRow = ketticGridView.Rows[ketticGridView.Rows.Count - 1]; lastRow.IsSelected = true;
foreach (GridViewRowInformation rowInformation in ketticGridView.Rows) { if (rowInfo.IsSelected) { rowInfo.beVisible(); } }
Find Grid Rows in C# GridView
The C# DataGridView provides the support of finding a grid row according to a specific value by iterating through the gird rows in GridView and gird cells value. The following is a sample that demonstrates how to search for searchedStr in PhotoColumnName grid column.
C# Code for Searching Grid Rows with Value of Grid Cell string searchedStr = "Photo 2"; for (int r = 0; r < ketticGridView.RowCount; r++) { if (ketticGridView.Rows[r].Cells["Photo Name"].Value.ToString().ToUpper().Equals(searchedStr.ToUpper())) { MessageBox.Display("Search a match"); } }
|