databound Checkbox list

4 posts, 1 answers
  1. Mike
    Mike avatar
    14 posts
    Member since:
    Mar 2008

    Posted 07 May 2008 Link to this post

    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.

  2. Answer
    Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 09 May 2008 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    14 posts
    Member since:
    Mar 2008

    Posted 09 May 2008 Link to this post

    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.
  5. Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 10 May 2008 Link to this post

    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
Back to Top