Accessing DataGridView row loads

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
 
P

Pavel Minaev

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top