I'm having a windows form which contains listview control ,
where listView1.View = View.Details;
and listView1.CheckBoxes = true;
then added a column with HeaderName as "FileName".
listView1.Columns.Add("File Name", 200, HorizontalAlignment.Left);
Here I would like to have check box in the Header of listview , ie FileName.
Can anyone help me with this.
Thanks in advance. andy
A ListView header with a checkbox is not part of the standard ListView functionality. You'll need to customise the renderering to do this:
listview.OwnerDraw = true
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
// Draw your custom checkbox control here
}
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
}
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
e.DrawDefault = true;
}
You'll also have to add some click handlers for the header and manage the state of your checkboxes yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With