Changing selectedindex from within selectedindexchanged event

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    1 posts
    Member since:
    Nov 2011

    Posted 27 Mar 2013 Link to this post

    When I am within a selectedindexchanged event of a listcontrol and I try to programmatically change the selectedindex value, the change does not take.  The concept is that "new" is the first item in the list and when "new" is selected an actual new record is inserted into the listcontrol and I want to position the selection to the new item.  The command does not error but the selectedindex does not change either.  This is also the case if you try to change it from the debugger.  Any suggestions on how to accomplish this?
  2. Peter
    Peter avatar
    1160 posts

    Posted 01 Apr 2013 Link to this post

    Hello Thomas,

    Thank you for writing.

    does not support changing the SelectedIndex in the SelectedIndexChangedEventHowever, you can try to clear the SelectedItems and set the DataLayer's CurrentPossition to the desired index in the SelectedIndexChanged. 

    Please, refer to the code below:
    private void radListControl_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
               this.radListControl1.ListElement.DataLayer.CurrentPosition = 5;
               this.radListControl1.Items[5].Selected = true;
               this.radListControl1.Items[5].Active = true;

    Please bear in mind that this scenario is not supported and we do not guarantee that this workaround will work correctly in all cases.

    Should you have any other questions, do not hesitate to contact us. All the best,
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
Back to Top