Insert Combo box, checkbox as an item into Listbox

2 posts, 0 answers
  1. Anshul
    Anshul avatar
    2 posts
    Member since:
    Mar 2013

    Posted 06 Mar 2013 Link to this post

    I need to create an UI which allows me to select entries from one list box and add it to another listbox at the run time. Now, the listbox1 may contain combo box and checkbox as the items. For example, if I add a combo box labelled Quarter with values "Q1, Q2, Q3, Q4" as an item in listbox1 and select the entry Q1 in it, and click on the "Add" button, it should be added to listbox2. Vice versa should also be possible. This should be possible at the run time. How could I add combo box and checkbox as an item to the listbox? Also, please suggest if for the add-remove buttons, the code I've is correct. Please look into the attachment for the UI which would help to understand this better.

    private void MoveListBoxItems(ListBox source, ListBox destination)
        {
            ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
            foreach (var item in sourceItems)
            {
                destination.Items.Add(item);
            }
            while (source.SelectedItems.Count > 0)
            {
                source.Items.Remove(source.SelectedItems[0]);
            }
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            MoveListBoxItems(listBox1, listBox2);
        }
    
        private void button2_Click(object sender, EventArgs e)
        {
            MoveListBoxItems(listBox2, listBox1);
        }
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 07 Mar 2013 Link to this post

    Hi Anshul,

    Thank you for writing.

    I am not sure that I understand your request clearly enough. 
    You can create a custom Visual Item for the RadListControl that contains any of our elements - please, refer to the this help article, which demonstrates how you can create a Custom Visual Item.

    I am attaching the sample project that demonstrates the idea of creating custom item with DropDownList inside and a method that moves the currently selected item from left the list to the right one.

    I hope this is a good basis for creating your application.

    All the best,
    Peter
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top