Checkbox on the header of a Listview
-
i have made this piece of code, to a checkbox on the header: wel not realy on the headr, but situated there. (class ColumnHeader doesn't provide much, like for example: OnpaintEvent. but i need some help with the special effects. if you hoover the mouse over the header, the mousehover effect of the header hides the checkbox, bringing it to the background. i would like to have the checkbox ontop @ all time. using windows 7.
using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Listview_Colum_header_checkbox { class CCehckBox : CheckBox { public CCehckBox() { Width = 14; Height = 14; //a //ValidationConstraints.Visible //AutoValidate.EnablePreventFocusChange; } protected override void OnPaint(PaintEventArgs pevent) { Invalidate(); base.OnPaint(pevent); } } class CListViewHeader : ColumnHeader { void CListViewHeader() { } } class CListview : ListView { private readonly CCehckBox _cCehckBox = new CCehckBox(); private readonly ColumnHeader _header1 = new ColumnHeader(); private readonly ColumnHeader _header2 = new ColumnHeader(); private readonly ColumnHeader _header3 = new ColumnHeader(); #region PInvoke Declarations [DllImport("user32")] private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); #endregion public CListview() { View = View.Details; _header1 = Columns.Add("Name"); _header1.Width = (Location.X + 5) + 6; _header1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); _header1.Name = "CheckBox"; _header1.DisplayIndex = 0; _header2 = Columns.Add("bah"); _header2.Width = (Width - 20) - 50; _header3 = Columns.Add("boh"); _header3.Width = 50; var wijd = _cCehckBox.Width; var hoog = _cCehckBox.Height; _cCehckBox.Location = new Point(Location.X+ 5, Location.Y + 5); } protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e) { if(e.ColumnIndex == 0) { //MessageBox.Show(e.ColumnIndex.ToString());
-
i have made this piece of code, to a checkbox on the header: wel not realy on the headr, but situated there. (class ColumnHeader doesn't provide much, like for example: OnpaintEvent. but i need some help with the special effects. if you hoover the mouse over the header, the mousehover effect of the header hides the checkbox, bringing it to the background. i would like to have the checkbox ontop @ all time. using windows 7.
using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Listview_Colum_header_checkbox { class CCehckBox : CheckBox { public CCehckBox() { Width = 14; Height = 14; //a //ValidationConstraints.Visible //AutoValidate.EnablePreventFocusChange; } protected override void OnPaint(PaintEventArgs pevent) { Invalidate(); base.OnPaint(pevent); } } class CListViewHeader : ColumnHeader { void CListViewHeader() { } } class CListview : ListView { private readonly CCehckBox _cCehckBox = new CCehckBox(); private readonly ColumnHeader _header1 = new ColumnHeader(); private readonly ColumnHeader _header2 = new ColumnHeader(); private readonly ColumnHeader _header3 = new ColumnHeader(); #region PInvoke Declarations [DllImport("user32")] private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); #endregion public CListview() { View = View.Details; _header1 = Columns.Add("Name"); _header1.Width = (Location.X + 5) + 6; _header1.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); _header1.Name = "CheckBox"; _header1.DisplayIndex = 0; _header2 = Columns.Add("bah"); _header2.Width = (Width - 20) - 50; _header3 = Columns.Add("boh"); _header3.Width = 50; var wijd = _cCehckBox.Width; var hoog = _cCehckBox.Height; _cCehckBox.Location = new Point(Location.X+ 5, Location.Y + 5); } protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e) { if(e.ColumnIndex == 0) { //MessageBox.Show(e.ColumnIndex.ToString());
Imho, your best bet would be to use a class derived from
ColumnHeader
[^]. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Imho, your best bet would be to use a class derived from
ColumnHeader
[^]. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
i tried that, but it doesn't look 'ColumnHeader' it provides me the nessesary properties to do this.
Bad = knowing 2 much