Avatar of vcharles
vcharles asked on

Help with seeing full text in wjen placing mouse of row of combobox

How do can I see all the text of a row  when I place the mouse on a row of my combo box using VB.NET?. The text is too long and not very user friendly not to be able to read the entire text.

Thanks,

Victor
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Jacques Bourgeois (James Burger)

8/22/2022 - Mon
adriankohws

You can drag and extend the length of a combobox. What you meant by not user-friendly?

This is not a good way of doing but just showing you some events you can make use of.
When you put your mouse there at this combobox2, the length will increase 200 pixels, but as I mentioned, you can always increase the width of the object in designer.

    Dim y As Integer = Me.Width
    Private Sub ComboBox2_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.MouseHover
        sender.Width = y + 200
    End Sub

    Private Sub ComboBox2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.MouseLeave
        sender.Width = y
    End Sub
Jacques Bourgeois (James Burger)

I do that with a ToolTip.

Simply add a ToolTip control to your form. It will fall in the control tray at the bottom of the form designer window.

In the SelectedIndexChanged event of the ComboBox, have code like the following:

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
          ToolTip1.SetToolTip(ComboBox1, ComboBox1.Text)
End Sub

Open in new window

The user simply has to hover over the ComboBox to see the full text.
ASKER
vcharles

I tried the tooltip bit it does not work, are you certain the code is in the right section? Also tried to include it in Mousemove section but still does not work.

Thanks.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER
vcharles

Hi,

  sender.Width = y does not returm the width to its original size.

Thanks
ASKER
vcharles

Tooltip works after you select a row, how do you get it to work when the dropdown list appears?
Jacques Bourgeois (James Burger)

To have the thing work before a selection is made, you have many options.

Set a default ToolTip text, either in the ComboBox properties (it has a ToolTip property once you add one on the form) or by calling ToolTip1.SetToolTip in the form load.

You can also trigger the SelectedIndexChanged when the form loads, and thus calling your code, either by typing the default selection text in the Text property of the form designer, or by setting the selection through code in the Load event of the form.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
vcharles

Sorry not clear, how do I set a default ToolTip text to see all text when I place the mouse on a row?
adriankohws

Can I have updates, what version of VS you guys using, my VS2005 doesn't have a tooltip for combobox.... I have no later VS versions yet.
Jacques Bourgeois (James Burger)

Add a line like the following in the Form_Load event, with any text that you want to show in the tooltip until the user makes a selection, or with the text that appears as the default entry in the ComboBox when it first show on the screen:

ToolTip1.SetToolTip(ComboBox1, "Use this list so select something")

or

ToolTip1.SetToolTip(ComboBox1, ComboBox1.Text)

This way the tooltip will display what you want before the user makes the first selection.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Jacques Bourgeois (James Burger)

@Adrian

The ToolTip property appears only after you put a ToolTip control on the form. This automatically adds a ToolTip property to all the controls on the form.

This is something that I talk about in my training sessions, and I kind of remember that it has been there since the very first version of the framework. So you should have it in 2005.
ASKER
vcharles

Hi,

I'm using visual studio 2010, I tried your approach but I don't see the full text unless I select a row. I need to see the full while the dropdown list appears as I move my mouse over the rows.

Thanks,

Victor
ASKER CERTIFIED SOLUTION
Jacques Bourgeois (James Burger)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
vcharles

Thanks.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
adriankohws

Funny, so isn't my first reply: You can drag and extend the length of a combobox. answered the question already??? lol.

And thanks for the reply regarding the tooltip, I have lost track, long didn't touch any coding, forgotten most of the things....
ASKER
vcharles

Hi,

Due to design issue, I was not able to increase the length of the combobox, but didn't know I could extend the size of the dropdown without extending the length of the control.

Thanks,

V.
Jacques Bourgeois (James Burger)

Note that you can use a combination of both suggestions. DropDownWidth for the list and the ToolTip when the list is closed.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck