C# DatagridView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Does anyone have sample code where I can highlight an entire row based on a
column or cell value?

Thanks,

-- Rich
 
I need to loop through the column cell values and look for a string then
highlight the row.
 
hi Sivana,
loop through entire table and get the rowindex of row which has that column
and then use Datagrid1.select(rowindex).
 
I understand the logic, I'm lacking some sample code. I'm not sure which
objects I need to look at.

A brief code sample of "looping through an entire table and look for
cell/column value" would be much helpful.

-R
 
this example displays value of each cells in datagrid
keep column no constant and iterate through rows

private void PrintCellValues(DataGrid myGrid){
int iRow;
int iCol;
DataTable myTable;
// Assumes the DataGrid is bound to a DataTable.
myTable = (DataTable) dataGrid1.DataSource;
for(iRow = 0;iRow < myTable.Rows.Count ;iRow++) {
for(iCol = 0;iCol < myTable.Columns.Count ;iCol++) {
Console.WriteLine(myGrid[iRow, iCol]);
}
}
}


i hope you get idea.
feel free to mail me at (e-mail address removed)
 
Back
Top