Datagridview loading rows

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top