Manually added items & RadToolTip

2 posts, 0 answers
  1. Adam
    Adam avatar
    3 posts
    Member since:
    Oct 2019

    Posted 25 Oct 2019 Link to this post

    Greetings,

    I have the following situation which I hope you can help me with.

    I have created a RadListBox control that shows icons only - no text. The purpose of this is to act like a menu. I am loading it manually by navigating through a dataset and creating RadListBoxItems, and then adding them to the RadListBox control (e.g.lstMenu.Items.Add(lbItem) ).  This works just fine.

     

    I now want to add a RadToolTip to each RadListBoxItem, but cannot seem to get it to work.

    I have tried the following:

                Dim item As New RadListBoxItem
                item.Value = dt.Rows(r).Item("MainMenuID")
                item.ImageUrl = String.Format("~/Images/{0}.png", iconName)
                item.Height = New Unit(32, UnitType.Pixel)
                item.Attributes.Add("tt", name)
                lstMenu.Items.Add(item)

                Dim tt As New RadToolTip
                tt.Text = name
                tt.TargetControlID = item.ClientID
                tt.IsClientID = True
                tt.Position = ToolTipPosition.MiddleRight
                tt.Animation = ToolTipAnimation.Fade
                tt.RelativeTo = ToolTipRelativeDisplay.Element
                tt.RenderInPageRoot = True
                tt.ShowEvent = ToolTipShowEvent.OnMouseOver
                tt.HideEvent = ToolTipHideEvent.LeaveTargetAndToolTip
                tt.AutoCloseDelay = 0
                tt.VisibleOnPageLoad = False

    ... but no tool tips appear over the list item.

    I also tried the following using a RadToolTipManager control:

    .aspx page:

    <telerik:RadToolTipManager runat="server" ID="ttMgr" Position="MiddleRight" Animation="Fade" RelativeTo="Element"              RenderInPageRoot="true" ShowEvent="OnMouseOver" HideEvent="LeaveTargetAndToolTip" AutoCloseDelay="0"              ShowCallout="true" VisibleOnPageLoad="false" />

    code behind

                Dim item As New RadListBoxItem
                item.Value = dt.Rows(r).Item("MainMenuID")
                item.ImageUrl = String.Format("~/Images/{0}.png", iconName)
                item.Height = New Unit(32, UnitType.Pixel)
                item.Attributes.Add("tt", name)
                lstMenu.Items.Add(item)

     

    Private Sub lstMenu_ItemCreated(sender As Object, e As RadListBoxItemEventArgs) Handles lstMenu.ItemCreated

        ttMgr.TargetControls.Add(e.Item.ClientID, e.Item.Attributes.Item("tt"), True)

    End Sub

     

    ... but again no tooltip.

    Can anyone please help me as to where I'm going wrong?

     

     

  2. Adam
    Adam avatar
    3 posts
    Member since:
    Oct 2019

    Posted 25 Oct 2019 in reply to Adam Link to this post

    Please ignore the above - I have managed to solve the issue. My code now looks like this:

    Dim item As New RadListBoxItem

    item.Value = dt.Rows(r).Item("MainMenuID")

    item.ImageUrl = String.Format("~/Images/{0}.png", iconName)

    item.Height = New Unit(32, UnitType.Pixel)

    item.Attributes.Add("tt", name)

    lstMenu.Items.Add(item)

    Dim tt As New RadToolTip

    tt.Text = name

    tt.TargetControlID = item.ClientID

    tt.IsClientID = True

    tt.Position = ToolTipPosition.MiddleRight

    tt.Animation = ToolTipAnimation.Fade

    tt.RelativeTo = ToolTipRelativeDisplay.Mouse

    tt.RenderInPageRoot = True

    tt.ShowEvent = ToolTipShowEvent.OnMouseOver

    tt.HideEvent = ToolTipHideEvent.LeaveTargetAndToolTip

    tt.AutoCloseDelay = 0

    tt.VisibleOnPageLoad = False

    tt.Skin = "Default"

    tt.OffsetX = 10

    form1.Controls.Add(tt) 'this was what was missing !

Back to Top