I need to display a dynamic list of options that a user can select, and they must be checkboxes because the user can select multiple items.
for now i am having to use a RadGrid to accomplish a hacked way to do this.
3 Answers, 1 is accepted
answered on 09 May 2008, 01:36 PM
Although RadGridView would possibly do the job, the best way to get a databound checkboxlist is to use RadListBox. You can do this by using the RadListBox.ListBoxElement.ItemDataBound event which fires on every data record during the binding process. You should attach to it when the form is initially created before the data source is filled with data or before binding the listbox control.
The code in the event handler should look like this:
RadListBoxItem item = e.DataBoundItem as RadListBoxItem;
item.Children.Children.Margin = new Padding(15, 0, 0, 0);
RadCheckBoxElement chBox = new RadCheckBoxElement();
chBox.StretchHorizontally = false;
chBox.StretchVertically = false;
This code changes the default structure of the RadListBoxItem and adds a RadCheckBoxElement. Finally, you'll further enhance the custom listbox item by adding mouse and keyboard events to set up your custom logic.
If you have any additional questions, please do not hesitate to write us.