Accessing DataGridView row loads

  • Thread starter Thread starter RDA
  • Start date Start date
R

RDA

This seems so trivial, but I am new to C#...

In a C# windows form I have a DataGridView that pulls from a database
(via an adapter), how can I access the event that loads each row? I
wish to format one of the cells based upon the data in another cell on
the same row (a very normal programmatic task) but cannot accomplish
this! What am I missing here?

Thanks much
 
This seems so trivial, but I am new to C#...

In a C# windows form I have a DataGridView that pulls from a database
(via an adapter), how can I access the event that loads each row? I
wish to format one of the cells based upon the data in another cell on
the same row (a very normal programmatic task) but cannot accomplish
this! What am I missing here?

If you need to change the way cells are displayed to the user, you
should handle the DataGridView.CellFormatting event.

Naturally, you can access the data source from your handler of that
event; or you can get the DataGridViewRow object of the cell using
e.RowIndex, and then use DataBoundItem to get the actual DataRow.
 
Back
Top