Add new item event in RadListControl

5 posts, 1 answers
  1. tran
    tran avatar
    8 posts
    Member since:
    Oct 2010

    Posted 20 Jan 2011 Link to this post

    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
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 20 Jan 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eric
    Eric avatar
    7 posts
    Member since:
    May 2012

    Posted 06 Jul 2012 Link to this post

    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
  5. Eric
    Eric avatar
    7 posts
    Member since:
    May 2012

    Posted 06 Jul 2012 Link to this post

    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
  6. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 10 Jul 2012 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready