简体   繁体   English

显示Datagridview行标题工具提示

[英]Show Datagridview Rowheader Tooltip

Greeting to all, 向所有人致意

Please help me how to set back again the tooltip text of row header of datagridview, When I load the datatable and set each tooltip for rows of datagridview, its show correctly when I move mouse pointer to row header but when I click the column to sort the data to ascending or descending the tooltip for the row header was remove ? 请帮助我如何重新设置datagridview行标题的工具提示文本,当我加载数据表并为datagridview行设置每个工具提示时,将鼠标指针移到行标题但单击列进行排序时,其显示正确行标题的工具提示的升序或降序数据已删除? how I can set it back or to avoid it when I clicking the column header of datagridview .... thanks in advance ! 当我单击datagridview的列标题时如何设置它或避免它....预先感谢!

Set ToolTipText property on DataGridViewColumn DataGridViewColumn上设置ToolTipText属性

foreach (DataGridViewColumn column in dataGridView1.Columns)
{
    column.ToolTipText = "Tooltip"; // set here.
}

Move the code that sets your row tooltips to the DataBindingComplete event handler. 将将行工具提示设置的代码移至DataBindingComplete事件处理程序。 This handle will trigger every time the DataSource updates (which includes sorting). 每当DataSource更新(包括排序)时,都会触发此句柄。 Like so: 像这样:

this.dataGridView1.DataBindingComplete += DataGridView1_DataBindingComplete;

private void DataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
    foreach (DataGridViewRow row in this.dataGridView1.Rows)
    {
        row.HeaderCell.ToolTipText = "ToolTip Text";
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM