This is a migrated thread and some comments may be shown as answers.

Item Selected but not Checked

2 Answers 80 Views
CheckedDropDownList
This is a migrated thread and some comments may be shown as answers.
Marianne
Top achievements
Rank 1
Veteran
Marianne asked on 17 Jun 2020, 12:41 PM

A checkboxdropdownlist is used to filter data for a chart.  After the initial load of list items the first item in the list is selected - even though it is not checked.  Turning it off in code doesn't work either.

 

for (i = 0; i < theRoot.ChildNodes.Count; i++)
{
    ServerName = theRoot.ChildNodes[i].Attributes["Name"].Value;
    foreach (XmlNode aNode in theRoot.ChildNodes[i])
    {
        if (aNode.InnerText == Environment)
        {
            sb = new StringBuilder();
            sb.Append(ServerName.Replace("XX", aNode.InnerText));
            lItem = new Item(j, sb.ToString());
            lvServers.Add(lItem);
            j++;
        }
    }
}
 
rcddlServers.DataSource = lvServers;
rcddlServers.ValueMember = "id";
rcddlServers.DisplayMember = "description";
rcddlServers.DropDownListElement.SelectionMode = SelectionMode.MultiSimple;
if (rcddlServers.SelectedItems.Count > 0) --> why is this possible?
{
    rcddlServers.Items[0].Checked = false;
}

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Jun 2020, 12:27 PM

Hello Marianne,

When you have a data-bound RadCheckedDropDownList (DataSource property is set to some data source), the first item in the collection is selected after the initial loading and this is normal behavior. If you want to remove the initially selected item you can set the SelectedIndex property of the control to -1. It is good to happen in the Load event of the form:

private void RadForm1_Load(object sender, EventArgs e) {
this.radCheckedDropDownList1.CheckedDropDownListElement.SelectedIndex = -1;
}

I hope this helps. Should you have other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Marianne
Top achievements
Rank 1
Veteran
answered on 18 Jun 2020, 01:41 PM

yes that fixed it

Tags
CheckedDropDownList
Asked by
Marianne
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Marianne
Top achievements
Rank 1
Veteran
Share this question
or