Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Whenever the checkbox is checked the corresponding item should be selected and vice versa

What I have tried:

Itemchecked event i just assign the selected property to the checked item
Example :
C#
private void listview_ItemChecked(object sender, ItemcheckedEventArgs e) 
{
   e. item. Selected = e. item. Checked;
}
Posted
Updated 17-Mar-16 20:26pm
v2
Comments
Mohammad Reza Valadkhani 15-Mar-16 9:02am    
Could you explain more about your problem

1 solution

List listBox2_selectionhistory = new List();

private void checkedListBox2_SelectedIndexChanged(object sender, EventArgs e)
{
int actualcount = listBox2_selectionhistory.Count;
if (actualcount == 1)
{
if (Control.ModifierKeys == Keys.Shift)
{
int lastindex = listBox2_selectionhistory[0];
int currentindex = checkedListBox2.SelectedIndex;
int upper = Math.Max(lastindex, currentindex) ;
int lower = Math.Min(lastindex, currentindex);
for (int i = lower; i < upper; i++)
{
checkedListBox2.SetItemCheckState(i, CheckState.Checked);
}
}
listBox2_selectionhistory.Clear();
listBox2_selectionhistory.Add(checkedListBox2.SelectedIndex);
}
else
{
listBox2_selectionhistory.Clear();
listBox2_selectionhistory.Add(checkedListBox2.SelectedIndex);
}
}
i thnk this should help u
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900