winforms Tooltip in winforms DataGridViewImageColumn

孤街醉人 提交于 2019-12-06 12:18:28

问题


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?


回答1:


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 = "..."


来源:https://stackoverflow.com/questions/1561119/winforms-tooltip-in-winforms-datagridviewimagecolumn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!