简体   繁体   中英

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 ? how I can set it back or to avoid it when I clicking the column header of datagridview .... thanks in advance !

Set ToolTipText property on DataGridViewColumn

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

Move the code that sets your row tooltips to the DataBindingComplete event handler. This handle will trigger every time the DataSource updates (which includes sorting). 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";
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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