views:

234

answers:

1

Hi again!

I have the following code that successfully displays an image in its column based on its bound DataProperty:

  private void dgvTasks_CellFormatting( object sender, DataGridViewCellFormattingEventArgs e ) {
        if (dgvTasks.Columns[e.ColumnIndex] is DataGridViewImageColumn && e.ColumnIndex == 1) {
            e.Value = ( (bool)e.Value == true ) ? Properties.Resources.ok : Properties.Resources.clock;
        }
  }

but I would like to know how its possible to show a tooltip when a user hovers over the image?

+2  A: 

generally if you have row & column for a cell, you can set a ToolTipText using:

dataGridView1.Rows[rowIndex].Cells[columnIndex].ToolTipText = "..."

and in your case, you have e.RowIndex and e.RowIndex:

dgvTasks.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = "..."
najmeddine
woa..that was quickU R A STAR!!! thank u much! dont know why i didnt think of that? anyway, now that I have that, I can work out the logic to determine the tooltiptext. Thanks again.
Shalan