Home:ALL Converter>Checking the checkbox of a Listview

Checking the checkbox of a Listview

Ask Time:2017-08-16T21:32:20         Author:Ismail Gunes

Json Formatter

I'm using 2008 and .NET 3.5

I want to check the checkboxes of my ListView.

When I click on checkbox even if i click on 6th row first and 6th checkboxes are both checked, but if i click somewhere else, not on checkbox, the checkbox of this row is checked well.

How ever as I changed the filter s >= 0 to s > 0 (which was causing checking the first and the checkbox I clicked at same time the both) Now for checking the the first checkbox either I should double click the row or on the checkbox. The rest of the rows with single click works well.

The method that i use for checking the checkboxes when clicked somewhere else (not on checkbox) is :

        int s = 0;
        try
        {
            s = rapview.FocusedItem.Index;
        }
        catch (NullReferenceException)
        {
            return;
        }
        if (trsfLst && s > 0)
        {
            rapview.FocusedItem.Checked = !rapview.FocusedItem.Checked;
            rapview.FocusedItem.Focused = false;
            GetListSum(true);
            return;
        }
        if (rapview.SelectedItems.Count == 0 || trsfLst)
            return;

What I look for is there way to detect if I clicked on checkbox or somewhere else (on a row) ?

PS: trsfLst is a control that tells if i am in checking the checkboxes or update mode the rest of the method depends of trsfLst is true or false.

Author:Ismail Gunes,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45715029/checking-the-checkbox-of-a-listview
yy