Datagridview loading rows

G

Guest

I think this a simple question but i'm breaking my brain without results.

I've a datagridview bounded to a datatable, with an imagecolumn that should
contain a different bitmap depending from a field in the bounded datatable.

my problem is to find an event raised for each rows loaded in the
datagridview, so
i can check my field and load the correct bitmap.

i tried RowsAdded event but it is raised only 2 times, even i'm loading 15
rows;
i tried also CellValueNeeded with the datagridview in virtual mode, but
e.RowIndex
was always 0

Example

Datatable rows
XXXXXX A -> need to load d.ico
YYYYYYY B -> need to load e.ico
ZZZZZZZ C -> need to load f.ico


my actual code (where dgvCards is mi datagridview)

if
(((DataTable)dgvCards.DataSource).Rows[e.RowIndex]["schtip"].ToString().Trim() == "S")
dgvCards.Rows[e.RowIndex].Cells["imagecolumn"].Value =
Properties.Resources.eico;
else
dgvCards.Rows[e.RowIndex].Cells["imagecolumn"].Value =
Properties.Resources.dico;


where do i need to put my code ?
thanks a lot
 
M

Mike Blake-Knox

my problem is to find an event raised for each rows loaded in the
datagridview, so
i can check my field and load the correct bitmap.

I'm using the CellFormatting event to assign a background color based
on the value in a cell.

Mike
 

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