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

Manually added items & RadToolTip

1 Answer 76 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 25 Oct 2019, 09:51 AM

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?

 

 

1 Answer, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 25 Oct 2019, 10:35 AM

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 !

Tags
ListBox
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Share this question
or