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

RadListBox values

1 Answer 52 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
R
Top achievements
Rank 1
R asked on 13 Jun 2008, 11:13 AM
Hi. I need to store two values in each of the items of the radlistbox. I'm trying this:

    Class MyItem 
        Inherits Telerik.WinControls.RadItem 
        Public MyShowText As String 
        Public MyStrng As String 
        Sub New(ByVal ShowText As StringByVal Strng As String
            MyBase.New() 
            MyShowText = ShowText 
            MyStrng = Strng 
            Me.Text = MyShowText 
        End Sub 
    End Class 
 
    ListBox1.Items.Add(New MyItem(Path.GetFileName(file_name), file_name)) 
 
 But the listbox is always empty.

Can you help me?

Thanks


1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 16 Jun 2008, 09:13 AM
Hello R,

Thank you for writing.

To display both text values in a listbox item, you could use the Text and Description properties of RadListBoxItem. I'm not sure what exactly is the case, but if the values are not textual, you may also create your own descendant of RadListBoxItem which adds additional properties to suit your needs. Alternatively, you can use the Tag property to store any value associated with a particular item.

Nevertheless, although the RadListBox.Items collection can accept instances of RadItem, direct instantiation of this class is not enough to show anything in the RadListBox. This is due to the architecture of our controls, and the role of the RadItem as an abstract class (please read more about this in our documentation: http://www.telerik.com/help/winforms/architecture_elementsoverview.html ).

If you have any additional questions, please don't hesitate to write.

Best wishes,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
R
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or