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

databound Checkbox list

3 Answers 61 Views
New Product Suggestions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 07 May 2008, 05:54 PM
I am in need of a databound checkboxlist.

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

Sort by
0
Accepted
Georgi
Telerik team
answered on 09 May 2008, 01:36 PM
Hi Mike,

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:

    private void ListBoxElement_ItemDataBound(object sender, ItemDataBoundEventArgs e)  
    {  
        RadListBoxItem item = e.DataBoundItem as RadListBoxItem;  
        item.Children[2].Children[1].Margin = new Padding(15, 0, 0, 0);  
        RadCheckBoxElement chBox = new RadCheckBoxElement();  
        chBox.StretchHorizontally = false;  
        chBox.StretchVertically = false;              
        item.Children.Add(chBox);   
    } 

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.

Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mike
Top achievements
Rank 1
answered on 09 May 2008, 01:51 PM
although i would much prefer to have a declarative control that set design time properties on, your suggested solution does work for what i need.

I would still like to request that a RadCheckBoxList control be created and added to future releases.


Thanks for your assistance.
0
Georgi
Telerik team
answered on 10 May 2008, 11:13 AM
Hi Mike,

Thank you for suggestion.

We definitely intend to include such a control in future versions of our product. However, I cannot tell you exactly for which release it will be scheduled.

Regards,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
New Product Suggestions
Asked by
Mike
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Mike
Top achievements
Rank 1
Share this question
or