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

Just an Items.Add question

2 Answers 50 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
William Gollnick
Top achievements
Rank 1
William Gollnick asked on 02 May 2011, 06:41 PM
I'm new to these controls. Normally to add an item to a listbox webcontrol I just had to do
 --->>>>  listbox1.items.add("value here") and all was right with the world

Now using the RadListBox I can not do this. I have tried using the RadListBoxItem
DIm itemout as RadListBoxItem
itemout.text = "some value"
radlistbox1.Items.add(itemout)        

BUT using this approach I get compiler error

--->>    Could not find a match for method 'RadListBox1.Items.Add' for the given parameter types: String.

How do I just add a simple value to my listbox???

Help

gollnick

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 May 2011, 06:47 AM
Hello Wiliam,

Here is a sample code to achieve your requirement.
aspx:
<telerik:RadListBox ID="RadListBox1" Height="150px"  runat="server". . . . . . >
</telerik:RadListBox>

VB:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
    Dim item As New RadListBoxItem()
    item.Text = "New"
    RadListBox1.Items.Add(item)
End Sub

Also take a look at the following demo.
ListBox / Add/Remove/Disable items.

Thanks,
Shinu.
0
William Gollnick
Top achievements
Rank 1
answered on 03 May 2011, 11:22 AM
Thank you ... I did not (duh) NEW the item first........
Tags
ListBox
Asked by
William Gollnick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
William Gollnick
Top achievements
Rank 1
Share this question
or