I want to Check/Uncheck the ListView's Header Checkbox When all the Item's Checkbox are either checked or Unchecked.But i am not able to access the object of Header's CheckBox. I used CheckBoxRenderer Class to create a checkbox.
private void ListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.DrawBackground();
bool value = false;
try
{
if (e.Header.Tag != null)
value = !Convert.ToBoolean(e.Header.Tag);
else
value = true;
}
catch (Exception)
{
}
//I want object of this CheckBox that i am drawing.
CheckBoxRenderer.DrawCheckBox(e.Graphics,
new Point(e.Bounds.Left + 4, e.Bounds.Top + 4),
value ? System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal :
System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
}
else
{
e.DrawDefault = true;
}
}
private void ListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
}
private void ListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
e.DrawDefault = true;
}
private void ListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
//Some Code
}
Is there any way to get the Object of Checkbox that i have created using CheckBoxRenderer.DrawCheckBox()