【问题标题】:Datagridview adding tooltipDatagridview 添加工具提示
【发布时间】:2011-11-16 14:35:38
【问题描述】:

我正在使用变量向数据网格视图添加列

UserVGrid.Columns.Add(newline[1], newline[1]);

效果很好,但是当我将鼠标悬停在列描述上时,我似乎无法弄清楚如何添加工具提示。

我想要一些类似的东西

UserVGrid.newline[1].tooltip = "some text in here"

但是这是不允许的,谁能告诉我正确的代码吗?

问候

亚伦 (DEvilWAH)

【问题讨论】:

    标签: c# winforms datagrid datagridview


    【解决方案1】:

    您需要设置ToolTipText。它是DataGridViewColumn 的属性。

    这是一种可能的解决方案:

    DataGridViewColumn newColumn = new DataGridViewColumn();
    newColumn.Name = newline[1];
    newColumn.HeaderText = newline[1];
    newColumn.ToolTipText = "some text in here";
    
    UserVGrid.Columns.Add(newColumn);
    

    或者,您可以参考添加后的列来设置ToolTipText属性:

    int newColIdx = UserVGrid.Columns.Add(newline[1], newline[1]);
    UserVGrid.Columns[newColIdx].ToolTipText = "some text in here";
    

    【讨论】:

    • 非常感谢,最喜欢第一种方法 ;) 不得不更改 new DataGridViewColumn();到新的 DataGridViewTextBoxColumn();。但这是一个很好的方法,它可以完美地完成我需要做的其他事情。干杯
    猜你喜欢
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2014-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多