This is a migrated thread and some comments may be shown as answers.

Assign Value to tooltiptext

4 Answers 162 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 23 Jan 2013, 11:29 AM
Hello,
I fail to assign a specific value to the tooltiptext of a drop down list,
in the past I used  the Tooltiptextneed event as follows
:
    Private Sub ddCountry_ToolTipTextNeeded(sender As Object, e As Telerik.WinControls.ToolTipTextNeededEventArgs) Handles ddCountry.ToolTipTextNeeded
        e.ToolTipText = ddCountry.SelectedItem("Label")
    End Sub

But is seemed to be not working anymore

I tried the following:

    Private Sub ddCountry_VisualListItemFormatting(sender As Object, args As VisualItemFormattingEventArgs) Handles ddCountry.VisualListItemFormatting
        args.VisualItem.ToolTipText = ddCountry.SelectedItem("Label")
    End Sub

But the selected index seems to be always "0" ant not the index of the Item on which I want to set the tooltip

How Should I set the tooltiptext to display the desired text ?

Thanks in advance
 

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Jan 2013, 09:43 AM
Hi Pierre-Jean,

Thank you for writing.

If I understand correctly, you want to show a tooltip when the users hovers the drop down control. If so, you can do that in the ToolTipTextNeeded event. Here is how to assign the tooltip from the selected item:
Private Sub ddCountry_ToolTipTextNeeded(sender As Object, e As Telerik.WinControls.ToolTipTextNeededEventArgs) Handles ddCountry.ToolTipTextNeeded
       If ddCountry.SelectedItem IsNot Nothing Then
           e.ToolTipText = ddCountry.SelectedItem.Text
       End If
   End Sub

To assign tooltips to the items in the drop down, you can use the VisualItemFormattingEvent:
Private Sub ddCountry_VisualListItemFormatting(sender As Object, args As VisualItemFormattingEventArgs) Handles ddCountry.VisualListItemFormatting
       If ddCountry.SelectedItem IsNot Nothing Then
           args.VisualItem.ToolTipText = args.VisualItem.Text
       End If
   End Sub

As to the case where the SelectedIndex is always 0, I was not able to reproduce it on my end. Please provide me with a sample project where the issue can be reproduced, so we can investigate it and provide you with further assistance.

I hope this helps.

Greetings,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 28 Jan 2013, 03:06 PM
Hello and thanks for your reply, I am sorry, my question was not very clear, but I can not get the desired effect:

1. the "ToolTipTextNeeded" event allows me to display the desired information ( item("Name").text) on the selected item When I move the cursor on it after having selected an item in the list.

2. the "VisualListItemFormatting" displays the item text when the cursor moves over the opened list of items and it displays in the tooltiptext the same information as in the list itself (of little use ...)

I would like to display a complementary information , available from the item("Name").text property when the cursor moves over each of the item in opened list

If I rember correctly I had this result before I moved to the latest versin of the WinForms Components, but this is some time ago and my memory may well be worn out ...

thanks in advance.

0
Stefan
Telerik team
answered on 31 Jan 2013, 08:57 AM
Hello Pierre-Jean,

Thank you for writing back.

I did not understand initially that you have your control bound and you want to access a field in the data bound object. You can do that by using the DataBoundItem property of the data item. Attached you can find a sample project demonstrating this.

I hope that you find this information useful.

Regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 05 Feb 2013, 08:12 AM
Thanks a lot,
this is exactly the result I was looking for
Best Regards
Pierre-Jean
Tags
DropDownList
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Stefan
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Share this question
or