Setting SelectionMode and SortStyle at desing time show false selections in some situations

5 posts, 0 answers
  1. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 29 May 2012 Link to this post

    Hello,

    I observed a behavior of RadListControl which shows false results. I could reproduce it with this code:

    using System.Windows.Forms;
    using Telerik.WinControls.Enumerations;
    using Telerik.WinControls.UI;
     
    namespace TestListboxSortAnSelection
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
     
                this.radListControl1.SelectionMode = SelectionMode.MultiExtended;
                this.radListControl1.SortStyle = SortStyle.Ascending;
     
                this.radListControl1.Items.Add(new RadListDataItem("Test 1"));
                this.radListControl1.Items.Add(new RadListDataItem("Test 3") { Selected = true });
                this.radListControl1.Items.Add(new RadListDataItem("Test 2") { Selected = true });
            }
     
            private void radButton1_Click(object sender, System.EventArgs e)
            {
                MessageBox.Show(string.Concat("Selected items: ",
                                              this.radListControl1.SelectedItems.Count));
            }
     
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.radListControl1 = new Telerik.WinControls.UI.RadListControl();
                this.radButton1 = new Telerik.WinControls.UI.RadButton();
                ((System.ComponentModel.ISupportInitialize)(this.radListControl1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.radButton1)).BeginInit();
                this.SuspendLayout();
                //
                // radListControl1
                //
                this.radListControl1.CaseSensitiveSort = true;
                this.radListControl1.ItemHeight = 18;
                this.radListControl1.Location = new System.Drawing.Point(12, 12);
                this.radListControl1.Name = "radListControl1";
                this.radListControl1.Size = new System.Drawing.Size(431, 312);
                this.radListControl1.TabIndex = 0;
                this.radListControl1.Text = "radListControl1";
                //
                // radButton1
                //
                this.radButton1.Location = new System.Drawing.Point(313, 330);
                this.radButton1.Name = "radButton1";
                this.radButton1.Size = new System.Drawing.Size(130, 24);
                this.radButton1.TabIndex = 1;
                this.radButton1.Text = "radButton1";
                this.radButton1.Click += new System.EventHandler(this.radButton1_Click);
                //
                // Form1
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(455, 366);
                this.Controls.Add(this.radButton1);
                this.Controls.Add(this.radListControl1);
                this.Name = "Form1";
                this.Text = "Form1";
                ((System.ComponentModel.ISupportInitialize)(this.radListControl1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.radButton1)).EndInit();
                this.ResumeLayout(false);
     
            }
     
            private Telerik.WinControls.UI.RadListControl radListControl1;
            private Telerik.WinControls.UI.RadButton radButton1;
        }
    }

    If SelectionMode is None, all works fine. Changing to One and SortStyle to Ascending it shows 2 selected items, but only 1 is selected. If SortStyle is Descending and Test 1 and 2 preselected then it shows also 2 selected items with one selected in list. Similar results occures with SelectionMode MultiSimple and MultiExtended. With SortStyle Ascending only 1 item is select on view and list. On SortStyle Descending it changes to 3 items on view and list.

    The work around of this bug?! is to set SortStyle after adding the items to Items list (in code, not during design time).


    Regards from Leipzig

    Holger Boskugel
  2. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 29 May 2012 Link to this post

    @Telerik Admins: Please move this thread to "DropDownList and ListControl"
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 31 May 2012 Link to this post

    Hello Holger,

    Thank you for reporting this to us.

    I would like to suggest manipulating the selection and sort order after adding the items into RadListControl .
    I have updated your Telerik point for the cooperation.

    Do not hesitate to contact us if you have other questions.

    All the best,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  5. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 31 May 2012 Link to this post

    Hello again,

    I have a next problem under this topic, not only the display of items makes trouble also selection in a sorted ListControl.

    Work around is sorting items before adding to Items collection and switch off sorting (SortStyle = None).


    Regards from Leipzig

    Holger
  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 05 Jun 2012 Link to this post

    Hi Holger,

    Thank you for bringing this to our attention and for sharing your workaround with the community.

    All the best,
    Peter
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready