Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Selecting all items in ultraListView programmatically
posted

Can anyone tell me how I can select all items in ultralistview.

----------------------

I have an ultralistview control in Form added at design time

When I load the form, I add items to the listview using "

           lstView.Items.Add("string1");

           lstView.Items.Add("string2");

          lstView.Items.Add("string3");

This adds 3 itmes to ultralistview.

When the user selects the option "Select all items" in the Form , then all three items should be selected [ highlighted ]

 

 

 

 

 

  • 69832
    Offline posted

    private void button1_Click(object sender, EventArgs e)
    {
        List<UltraListViewItem> items = new List<UltraListViewItem>(this.listView1.Items.Count);
        foreach( UltraListViewItem item in this.listView1.Items )
        {
            items.Add( item );
        }

        this.listView1.SelectedItems.AddRange( items.ToArray() );
    }