Assign Value to tooltiptext

5 posts, 0 answers
  1. pierre-jean
    pierre-jean avatar
    22 posts
    Member since:
    Apr 2011

    Posted 23 Jan 2013 Link to this post

    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
     

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Jan 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. pierre-jean
    pierre-jean avatar
    22 posts
    Member since:
    Apr 2011

    Posted 28 Jan 2013 Link to this post

    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.

  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Jan 2013 Link to this post

    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.
  6. pierre-jean
    pierre-jean avatar
    22 posts
    Member since:
    Apr 2011

    Posted 05 Feb 2013 Link to this post

    Thanks a lot,
    this is exactly the result I was looking for
    Best Regards
    Pierre-Jean
Back to Top
UI for WinForms is Visual Studio 2017 Ready