lundi 25 janvier 2021

How to check all the items in objectlistview c#?

I am using Objectlistview in my WFA to create a chekedlistbox. I want to have a button called "Select all" that the user can click on it and all the rows are selected just by one click. I have been using the following code which works and all the checkboxes will be selected

 private void btnSelectallModule_Click(object sender, EventArgs e)
    {
        
        foreach (ListViewItem item in dataListView1.Items)
        {
            item.Checked = true;
        }

    }

The problem is that when I check all the items using this button then I hover over each item it will be unchecked automatically without even clicking on that item, which is so weird because I did not intend to do that in the code. Does anyone know what is going on and how can I fix this? Thanks




Aucun commentaire:

Enregistrer un commentaire