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

RadListControl add/remove

3 Answers 470 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Devender
Top achievements
Rank 1
Devender asked on 12 May 2011, 11:16 AM
I am having two list boxes selected items should be added to listbox2 when i click on add from listbox1 and items should be deleted from listbox1  and vice verse please guide me in this regard

thanks & regards,
devender

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 16 May 2011, 09:53 AM
Hello,

In the demos on your PC where the Telerik Controls are installed is a good demo of using Drag and Drop with a RadListControl which of course also shows adding and removing items from 2 RadListBoxes.

If you need further help however, please let me know
Thanks
Richard
0
Sandesh
Top achievements
Rank 1
answered on 06 Nov 2012, 11:38 AM
Hi Richard,
I have seen the demo but I am still a bit confuse about exact working of same.
Can you please elobrate this using any event of list view?

As I am working on functionality of adding item from RadListControl to RadListView on single click and not drag and drop.
I have set the ViewType property of RadListView to ItemView.

I am using event of SelectedIndexChanged to add item to RadListView and at same time I am removing it from RadListControl.
Then on ItemRemoving event of radListView I am adding the same Item back to RadListControl.
While doing so I am getting exception of Collection can not be modified as it is read only.

Can you please help me with this?
0
Stefan
Telerik team
answered on 09 Nov 2012, 11:16 AM
Hello Sandesh,

Thank you for writing.

RadListView does not have a ViewType called ItemVIew. It has ListView, IconsView and DetailsView. 

As to the approach used, I would suggest that you use the MouseDown event. Here is a sample when RadListView is in ListView mode:
public Form1()
{
    InitializeComponent();
 
    radListControl1.MouseDown += radListControl1_MouseDown;
    radListView1.MouseDown += radListView1_MouseDown;
}
 
void radListView1_MouseDown(object sender, MouseEventArgs e)
{
    SimpleListViewVisualItem el = radListView1.ElementTree.GetElementAtPoint(e.Location) as SimpleListViewVisualItem;
    if (el != null)
    {
        radListControl1.Items.Add(el.Data.Text);
        radListView1.Items.Remove(el.Data);
    }
}
 
void radListControl1_MouseDown(object sender, MouseEventArgs e)
{
    RadListVisualItem el = radListControl1.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
    if (el != null)
    {
        radListView1.Items.Add(el.Data.Text);
        radListControl1.Items.Remove(el.Data);
    }
}

I hope this helps.
  
Kind regards,
Stefan
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
ListControl
Asked by
Devender
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Sandesh
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or