winforms - How to change listview header's forecolor? C# windows form application -
winforms - How to change listview header's forecolor? C# windows form application -
i know can alter ownerdraw
property true
, handle drawcolumnheader
event if this, have take care of in drawing header.
is there anyway alter foreground color , else drawn defaults?
how this:
create new winform project, drag listview command onto form, set ownerdraw = true, view = details in properties pane, handle drawcolumnheader event.
namespace windowsformsapplication1 { public partial class form1 : form { public form1() { initializecomponent(); this.setlastcolumnwidth(); this.thelistview.layout += delegate { this.setlastcolumnwidth(); }; } private void setlastcolumnwidth() { // forcefulness lastly listview column width occupy // available space. this.thelistview.columns[ this.thelistview.columns.count - 1 ].width = -2; } private void listview1_drawcolumnheader( object sender, drawlistviewcolumnheadereventargs e ) { // fill header background solid yello color. e.graphics.fillrectangle( brushes.yellow, e.bounds ); // allow listview draw else. e.drawtext(); } } }
c# winforms visual-studio listview
Comments
Post a Comment