Initial selection of ListControl is not shown.

2 posts, 0 answers
  1. Robert
    Robert avatar
    1 posts
    Member since:
    Feb 2014

    Posted 21 Feb 2014 Link to this post

    I have a RADListControl which requires scrolling in order to see all the items.  After the control is Initialized, I populate it and set the initial selection.  If that selection is beyond the initial visible range of the list, it is selected, but the list is not scrolled to make it visible.  (e.g., if I set SelectedIndex of the control with a list of 100 items to 50, item 50 is selected after the initial draw, but only items 0 through 20 are shown if the control is only tall enough to show 20 items.)

    Subsequent changes to the SelectedINdex work as expected - i.e., if I change the selection no an item that id beyond the current visible range of the list, then the list will scroll enough to make it visible.

    Is there a way to cause the initial selection to be displayed?  Sample code below.

    namespace ListBoxScrollTest
      public partial class Form1 : Form
        public Form1()

          for (int i = 0; i < 101; i++)

          numericUpDown1.Minimum = 0;
          numericUpDown1.Maximum = listBox1.Items.Count - 1;
          numericUpDown1.Value = (int)(listBox1.Items.Count/2);

          int init = (int)(numericUpDown1.Value);
          radListControl1.SelectedIndex = init;

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
          int val = (int)(numericUpDown1.Value);
          radListControl1.SelectedIndex = val;

  2. Dimitar
    Dimitar avatar
    2983 posts

    Posted 26 Feb 2014 Link to this post

    Hi Robert,

    Thank you for writing.

    You can use the ScrollToItem method in order to ensure that the item will be visible:
    private void Form1_Load(object sender, EventArgs e)

    Let me know if you have additional questions.

Back to Top