代码之家  ›  专栏  ›  技术社区  ›  Scott Chamberlain

数据绑定到工具提示

  •  3
  • Scott Chamberlain  · 技术社区  · 15 年前

    是否有任何方法可以将工具提示绑定到数据源。下面是一个简单的例子,说明我要做的事情。

    I have a DataTable with two columns, one is a datetime the other is a varchar. This DataTable is bound to a BindingSource. That binding source has its current record bound to a label displaying the datetime column. How can I get the varchar field associated with that row to show up in the tooltip when I hover over the label showing the date.

    我理解在执行静态文本时工具提示是如何工作的,我只是很难弄清楚如何使用动态源进行操作。

    另外,请在winforms中使用您的示例,我搜索的几乎所有示例都是基于wpf的。

    1 回复  |  直到 15 年前
        1
  •  1
  •   Scott Chamberlain    15 年前

    我不太喜欢这个答案,所以我希望有人能想出一个更好的答案(在我真正的代码中,我有大约30个字段可以弹出),但我可以这样做。

    dsMyRows_OnCurrentItemChanged(sender, EventArgs e)
    {
        ttPersonWhoDidAction.SetToolTip(lblDate, ((DataRowView)dsMyRows.Current)["TextValue"]);
    }
    
    推荐文章