By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

Datagridview loading rows

P: n/a
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
Mar 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <90**********************************@microsoft.co m>, Luca
Beretta wrote:
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

Mar 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.