Completed
Last Updated: 28 Nov 2017 06:43 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 23 Nov 2017 07:11
Category: ListView, CardView and CheckedListBox
Type: Bug Report
1
FIX. RadCheckedListBox - disabled items shouldn't be selected and toggled
To reproduce: use the following code to populate RadCheckedListBox:
            for (int i = 0; i < 10; i++)
            {
                this.radCheckedListBox1.Items.Add("Item" + i); 
            }
             this.radCheckedListBox1.Items[3].Enabled = false;

Handle the SelectedIndexChanged event:
        private void radCheckedListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine(this.radCheckedListBox1.SelectedIndex);
        }

If you run the application and navigate through the items by using the arrow keys you will notice that the SelectedIndexChanged event will be fired for the disabled item. Although it is not visually selected, the SelectedIndex of the control confirms that it is selected. Then, if you press the Space key you will notice that it is toggled.

Workaround: in order to prevent selecting a disabled item you can cancel the SelectedItemChanging event:

        private void radCheckedListBox1_SelectedItemChanging(object sender, Telerik.WinControls.UI.ListViewItemCancelEventArgs e)
        {
            if (e.Item.Enabled==false)
            {
                e.Cancel = true;
            }
        }
0 comments