RadListControl add/remove

4 posts, 1 answers
  1. Devender
    Devender avatar
    1 posts
    Member since:
    May 2011

    Posted 12 May 2011 Link to this post

    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
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 16 May 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sandesh
    Sandesh avatar
    1 posts
    Member since:
    Nov 2012

    Posted 06 Nov 2012 Link to this post

    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?
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 09 Nov 2012 Link to this post

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