我已经搜索了各种解决方案,但没有一个给我直接答案或者没有用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));