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

Setting 'Checked' value in RadComboBox

1 Answer 185 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 20 Jun 2011, 02:34 PM

I have a databound ComboBox that the application user needs to be able to 'check'.  What need to do is to show the user which entries have already been 'checked', that is I need to be able to programmatically set the checked property of the items in the combobox.  I can id the items to be checked, I just need the code to actually "check" the item.

Here is my code so far:

If item.IsInEditMode Then

Dim indx As Integer = ctlUserCombo.FindItemIndexByText("Test, Sabo")

Dim cmbo As RadComboBox = CType(item.FindControl("ctlUserCombo"), RadComboBox)

Dim cbox As RadComboBoxItem = CType(cmbo.Items(indx), RadComboBoxItem)

cmbo.Items(indx).Enabled = False

So I am able to change the Enabled property to False...what I need to be able to do is set the combobox to "Checked".  However the RadComboBoxItem does not have a 'checked' property.  Anyone know how to get the combo box to show checked = true for individual items in the combobox? 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jun 2011, 08:12 AM
Hello Rich,

You can use findControl() method to access the CheckBox. Here is the sample code.
C#:
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
  int indx = ctlUserCombo.FindItemIndexByText("Test, Sabo");
  RadComboBox cmbo = (RadComboBox)item.FindControl("ctlUserCombo");
  RadComboBoxItem cbox = (RadComboBoxItem)cmbo.Items(indx);
  CheckBox chk= (CheckBox)item.FindControl("CheckBox1");
  chk.Checked = true;
 }

Thanks,
Princy.
Tags
ComboBox
Asked by
Rich
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or