i am searching for an element whitch i can place in RadListbox that can highlight textpeases. My favorit was changing color in the text like:
abcdefghi
Can the RadListbox handle this?
Thanks for answers
Steve
3 Answers, 1 is accepted
Currently this is not possible "out of the box" even though you can still achieve the same effect by extending the ListBoxItem class and then add two more TextPrimitives in the CreateChildElements method. Then you can customize separately each text primitive. You can change separately each text size, font, color, etc.
I hope this information helps.
Sincerely yours,
Chris
the telerik team

i have try it. Now i have 3 text pieces in various colors. But the pieces was painted one on top of the other.
Protected Overrides Sub CreateChildElements()
MyBase.CreateChildElements()
Dim new_text As New Telerik.WinControls.Primitives.TextPrimitive()
new_text.Text = "Test"
new_text.ForeColor = Color.Red
Me.Children.Add(new_text)
End Sub
Can you tell me whats going wrong?
Thanks,
Steve
I'm sorry if I have misled you with my previous answer.
Yes, you can achieve this behavior but you should use some layout to arrange the new text primitives. By default each element uses a Canvas layout to position its elements and when you insert new elements in its structure they'll be positioned absolutely in the element's space.
I have created a sample class which demonstrates this approach:
Public Class MyListBoxItem
Inherits RadListBoxItem
Protected Overrides Sub CreateChildElements()
MyBase.CreateChildElements()
Dim layoutPanel As ImageAndTextLayoutPanel = CType(MyBase.Children(2), ImageAndTextLayoutPanel)
Dim stripPanel As StripLayoutPanel = CType(layoutPanel.Children(1), StripLayoutPanel)
Dim itemText As TextPrimitive = CType(stripPanel.Children(0), TextPrimitive)
Dim newStripPanel As StripLayoutPanel = New StripLayoutPanel()
newStripPanel.Orientation = Orientation.Horizontal
Dim redText As TextPrimitive = New TextPrimitive()
redText.ForeColor = Color.Red
redText.Text = " Red "
Dim blueText As TextPrimitive = New TextPrimitive()
blueText.ForeColor = Color.Blue
blueText.Text = " Blue "
stripPanel.Children.Remove(itemText)
newStripPanel.Children.AddRange(New RadElement() { itemText, redText, blueText })
stripPanel.Children.Insert(0, newStripPanel)
End Sub
End Class
You can easily enhance this class and expose the new primitives' Text properties as properties of the MyListBoxItem class.
Please, let me know if this works fine for you.
Best wishes,
Chris
the telerik team