Highlighting rows in a datagrid 
Author Message
 Highlighting rows in a datagrid

I am trying to get a C# datagrid (Windows forms) to highlight a row in a
different color based upon the contents of a cell.

I have overwritten the Paint event, based upon the following code example:
http://www.*-*-*.com/ #q745q

This works great, except that it only highlights a single cell instead of
the entire row.

My question is how can I highlight every cell in the row?  I've been looking
into the GetColumnValueAtRow() method, but I can't figure out how to change
the column focus.  What I want to do is

if the text in this row, column#9 equals "foo", then highlight this cell.

Thanks!

--- Bob Sillett



Thu, 02 Jun 2005 14:09:44 GMT  
 Highlighting rows in a datagrid
I'm answering my own question....

When in the overridden Paint event, you can query the value of any cell in
the DataGrid with the following line:

object oValue = this.DataGridTableStyle.DataGrid[RowNum,ColNum];

Based upon this line, you can then decide whether to highlight the column or
not.  You simply highlight every cell in a row to highlight the entire row.

--- Bob Sillett


Quote:
> I am trying to get a C# datagrid (Windows forms) to highlight a row in a
> different color based upon the contents of a cell.

> I have overwritten the Paint event, based upon the following code example:
> http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q745q

> This works great, except that it only highlights a single cell instead of
> the entire row.

> My question is how can I highlight every cell in the row?  I've been
looking
> into the GetColumnValueAtRow() method, but I can't figure out how to
change
> the column focus.  What I want to do is

> if the text in this row, column#9 equals "foo", then highlight this cell.

> Thanks!

> --- Bob Sillett



Thu, 02 Jun 2005 22:46:16 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. highlight row in datagrid from code?

2. Highlight a row in a DataGrid

3. Selecting/highlighting a row in a datagrid

4. How to avoid user from entering a new row into the datagrid[which already contains rows]

5. changing row colors in DataGrid (not a web DataGrid)

6. How to disable adding, inserting ord deleting Rows in the DataGrid (System.Windows.Forms.DataGrid)

7. How to Highlight Multiple rows in C# ListView

8. CListCtrl not maintaining highlight after deleting previous row

9. How highlight entire row in the CRichEditCtrl

10. Highlighting rows in Microsoft Flex Grid

11. CListCtrl and Row highlighting

12. how highlight entire row in the CRichEditCtrl

 

 
Powered by phpBB® Forum Software