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

Insert Combo box, checkbox as an item into Listbox

1 Answer 185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anshul
Top achievements
Rank 1
Anshul asked on 06 Mar 2013, 05:39 PM
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);
    }

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 07 Mar 2013, 04:41 PM
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.
Tags
General Discussions
Asked by
Anshul
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or