VB.NET里怎样给ComboBox各项设置各自的工具提示信息?

2026-05-06 13:142阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计356个文字,预计阅读时间需要2分钟。

VB.NET里怎样给ComboBox各项设置各自的工具提示信息?

我已经搜索了各种解决方案,但没有找到直接回答或使用VB.NET编写的。我的情况是有一个ComboBox,其中包含用户可以选择的项目。我想添加一个简单的工具提示,以便每个用户都知道他选择了什么。

我已经搜索了各种解决方案,但没有一个给我直接答案或者没有用vb.net编写.但我的情况是我有一个ComboBox,其中包含一些用户可以选择的项目.我想添加简单的工具提示,以便每个用户知道他或她正在选择什么.但是,在选择项目之前,工具提示不会显示.我希望工具提示显示鼠标悬停在每个项目上的时间.

以下是我的代码:

VB.NET里怎样给ComboBox各项设置各自的工具提示信息?

Private Sub VotingAgentComboBox_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VotingAgentComboBox.MouseHover Dim VotingAgentToolTip As New ToolTip If VotingAgentComboBox.Text = "ISS" Then VotingAgentToolTip.SetToolTip(VotingAgentComboBox, "You selected ISS") End Sub 试试这个..
将工具提示控件添加到您的表单,并将此代码写入DrawItem事件到组合框控件

并且combobox的drawmode属性设置为OwnerDrawFixed

if (e.Index == -1) { return; } Point p = new Point(ComboBox1.Location.X + 120, ComboBox1.Location.Y + ComboBox1.Height + (30 + e.Index * 10)); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { toolTip.Show(ComboBox1.Items[e.Index].ToString(), this, p); } e.DrawBackground(); e.Graphics.DrawString(ComboBox1.Items[e.Index].ToString(), e.Font, Brushes.Black, new Point(e.Bounds.X, e.Bounds.Y));

标签:每个

本文共计356个文字,预计阅读时间需要2分钟。

VB.NET里怎样给ComboBox各项设置各自的工具提示信息?

我已经搜索了各种解决方案,但没有找到直接回答或使用VB.NET编写的。我的情况是有一个ComboBox,其中包含用户可以选择的项目。我想添加一个简单的工具提示,以便每个用户都知道他选择了什么。

我已经搜索了各种解决方案,但没有一个给我直接答案或者没有用vb.net编写.但我的情况是我有一个ComboBox,其中包含一些用户可以选择的项目.我想添加简单的工具提示,以便每个用户知道他或她正在选择什么.但是,在选择项目之前,工具提示不会显示.我希望工具提示显示鼠标悬停在每个项目上的时间.

以下是我的代码:

VB.NET里怎样给ComboBox各项设置各自的工具提示信息?

Private Sub VotingAgentComboBox_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VotingAgentComboBox.MouseHover Dim VotingAgentToolTip As New ToolTip If VotingAgentComboBox.Text = "ISS" Then VotingAgentToolTip.SetToolTip(VotingAgentComboBox, "You selected ISS") End Sub 试试这个..
将工具提示控件添加到您的表单,并将此代码写入DrawItem事件到组合框控件

并且combobox的drawmode属性设置为OwnerDrawFixed

if (e.Index == -1) { return; } Point p = new Point(ComboBox1.Location.X + 120, ComboBox1.Location.Y + ComboBox1.Height + (30 + e.Index * 10)); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { toolTip.Show(ComboBox1.Items[e.Index].ToString(), this, p); } e.DrawBackground(); e.Graphics.DrawString(ComboBox1.Items[e.Index].ToString(), e.Font, Brushes.Black, new Point(e.Bounds.X, e.Bounds.Y));

标签:每个