c# - Fit ColumnHeaders to ListView's width, this code needs an explanation and wonder if there is a standard way? -
i found code (a loop) can fit total width of columnheaders width of listview (of course if listview's width large enough, otherwise there horizontal scrollbar displayed).
foreach(columnheader ch in mylistview.columns){ ch.width = -2; } i've tried changing value -2 other values , didn't work. need explanation on code, why have -2 , not other?
by way, if possible know other (standard?) way (fit total width of columnheaders width of listview)?
your highly appreciated!
there no automatic way beyond have found. documented @ http://msdn.microsoft.com/en-us/library/windows/desktop/bb761163(v=vs.85).aspx though can't see value lvscw_autosize_useheader, -2.
in order yourself, need react listview being resized, , calculate widths yourself. there event resizing. use listview.clientsize.width - systeminformation.verticalscrollbarwidth total width account scrollbar.
Comments
Post a Comment