| I need an event to be raised when mouse hovers over Combo Box
items so that I could provide ToolTip for Items of dropDownArea of ComboBox.
how to get index of comboBoxItem pointed by cursor ? Thanks in advance. |
Loading
| I need an event to be raised when mouse hovers over Combo Box
items so that I could provide ToolTip for Items of dropDownArea of ComboBox.
how to get index of comboBoxItem pointed by cursor ? Thanks in advance. |
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
pooja chavanPosted Oct 19, 2014, 9:30 PM
Hi All,
I want to show tooltip for Comboboxedit control of devexpress can anyone help me? I am still unable to fix it even after following all above suggestions
need urgent help/suggestion
Appreciate all ur help
krishnan sriramPosted Nov 5, 2010, 12:46 PM
There are 2 ways by which you can see tooltips for the dropdown items of a combobox.
1. Create a customControl - If you desire to have your style, font, background for tooltips
2. Override DrawItem of combobox
I have taken Item 2 and here's a simple example. You may need to play around with the X & Y xo-orinates to get things right
Manikavelu VelayuthamPosted Oct 21, 2010, 6:40 AM
I have uploaded the sample screen shot of what i would like to say. Just view the image, you will come to know.
Above code will display the tool tip after the selection of item from the list. Once you selected the item, if you move your mouse over the combo box, tooltip will be shown.
But it wont show the tooltip when you move the mouse over the selection items of the combo box as shown in the image.
Suthish NairPosted Oct 21, 2010, 6:38 AM
Suthish NairPosted Oct 21, 2010, 6:14 AM
At any point of logic there will a value binded to the CombobBox,
that will a SelectedItem, SelectedText, SelectedValue or simply Text.
you can use following....
Manikavelu VelayuthamPosted Oct 21, 2010, 5:55 AM
This event will fire on mouse hover of the combo box and not on mouse hover of the selection list.
I tried this already.
Suthish NairPosted Oct 21, 2010, 5:41 AM
My first reply with an example is because of you said its not supported.
Now about MouseHover, did you tried to test the code before posting replys.
You can use MouseHover event to show the toolitips also.
But am not sure you can make a customised ToolTip with colors, font etc with VS 2003.
Lakshmi RamyaPosted Oct 21, 2010, 4:40 AM
Manikavelu VelayuthamPosted Oct 21, 2010, 4:29 AM
Window that popup on hover of the mouse is called tool tip.
Thats why i preferred to have a label to display the item name fully.
Suthish NairPosted Oct 21, 2010, 3:56 AM
Manikavelu VelayuthamPosted Oct 21, 2010, 3:33 AM
You can put a label next to combobox and display the items text in it after selecting the item from the combobox.
Thats it you cand do.
Lakshmi RamyaPosted Oct 21, 2010, 3:27 AM
Manikavelu VelayuthamPosted Oct 21, 2010, 3:19 AM
Is it a Windows Application or Web Application ?
Lakshmi RamyaPosted Oct 21, 2010, 3:00 AM
for (int i = 0; i < comboxBox1.Items.Count; i++)
{
//DropDownList1.Items[i].Attributes.Add("title", DropDownList1.Items[i].Text);
}
Manikavelu VelayuthamPosted Oct 21, 2010, 2:51 AM
for (int i = 0; i < DropDownList1.Items.Count; i++)
{
DropDownList1.Items[i].Attributes.Add("title", DropDownList1.Items[i].Text);
}
Lakshmi RamyaPosted Oct 21, 2010, 2:12 AM
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Combobox_tooltip
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private ToolTip toolTip1;
private System.Windows.Forms.ComboBox comboBox1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"ramya",
"lakshmiramya",
"abcdefghijklmnopqrstuvwxyz",
"abcdefghijklm",
"abcdefghijklmraqeewf",
"yxwvutsrqponmlkjihgf",
"zyxwvutsrqponmlkjihgfedcba"});
this.comboBox1.Location = new System.Drawing.Point(64, 56);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 21);
this.comboBox1.TabIndex = 0;
this.comboBox1.Text = "comboBox1";
this.toolTip1.SetToolTip(comboBox1,comboBox1.Text);
this.comboBox1.MouseHover += new System.EventHandler(this.comboBox1_MouseHover);
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 0;
this.toolTip1.InitialDelay = 0;
this.toolTip1.ReshowDelay = 0;
this.toolTip1.ShowAlways = true;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.comboBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
toolTip1.SetToolTip(comboBox1,comboBox1.SelectedItem.ToString());
}
private void comboBox1_MouseHover(object sender, EventArgs e)
{
MessageBox.Show(comboBox1.SelectedText);
}
//
// This method binds tooltip with a dropdown/ any list control
//
public static void BindTooltip(ListControl lc)
{
for (int i = 0; i < lc.Items.Count; i++)
{
lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
}
}
}
}
Manikavelu VelayuthamPosted Oct 21, 2010, 2:01 AM
Lakshmi RamyaPosted Oct 21, 2010, 1:57 AM
can we have the same for combobox??
Manikavelu VelayuthamPosted Oct 21, 2010, 1:32 AM
//
// This method binds tooltip with a dropdown/ any list control
//
public static void BindTooltip(ListControl lc) { for (int i = 0; i < lc.Items.Count; i++)
{
lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
}
}