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

Add new item event in RadListControl

4 Answers 191 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
tran
Top achievements
Rank 1
tran asked on 20 Jan 2011, 08:52 AM
Hi Telerik Team! I have a question about RadListControl. I have a RadListControl, which event will I catch up the event when a new RadListDataItem insert into my RadListControl ?

Thanks
Tran Dat

4 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 20 Jan 2011, 12:21 PM
Hello,

There are two ways for this. If you are binding to a datasource then you can use

AddHandler Me.RadListControl1.ItemDataBound, AddressOf RadListControl_ItemDataBound
  
    Private Sub RadListControl_ItemDataBound(ByVal sender As Object, ByVal e As ListItemDataBoundEventArgs)
        MessageBox.Show(e.NewItem.Text)
    End Sub

or, when adding items, you can subscribe to the ItemsChanged event
AddHandler Me.RadListControl1.ListElement.ItemsChanged, AddressOf RadListControl_ItemsChanged
  
    Private Sub RadListControl_ItemsChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.Data.NotifyCollectionChangedEventArgs)
        MessageBox.Show(CType(e.NewItems(0), RadListDataItem).Text)
    End Sub


Hope that helps
Richard
0
Eric
Top achievements
Rank 1
answered on 06 Jul 2012, 02:50 PM
Hi!

I just have a tiny question for this:
Do I have to add the handler manually at the code for the RadListControl_ItemsChanged Event?
The ItemDataBound I can find at the NavigationBar, but not the ItemsChanged (Maybe because it's from the ListElement Property)

Is that right?
Thanks in advance,
Eric
0
Eric
Top achievements
Rank 1
answered on 06 Jul 2012, 03:03 PM
Also, this event, the ItemsChanged, has being triggered unstoppable until I get a stack overflow. Is this the right event to catch the add of an ListItem in the list? (In this particular case I'm not working with a Data Binding).

Thanks,
Eric
0
Stefan
Telerik team
answered on 10 Jul 2012, 11:46 AM
Hello Tran,

Thank you for writing.

Indeed the event belongs to the ListElement and you have to manually subscribe to it. 

Yes, this is the right event to capture changes in an item. The event arguments allow you to check what is the action that triggered the event.

I hope this information addresses your question. If there is anything else I can assist you with, do not hesitate to contact me.

Regards,
Stefan
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Tags
ListControl
Asked by
tran
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Eric
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or