layout - How can I make sure a ListView item always resizes to show all rows? -
I have a panel that has a TableLayoutPanel
, which contains many ListViews
And labels
.
For each list view, I want to shape it to fit all the content vertically (i.e., each row is visible). TableLayoutPanel
should handle any vertical scroll but I can not work to get ListView
to change the size of the rows based on the number of rows.
Do I need to handle ONResize
and manually resize or is it already something? >
Such a question was suggested to use, but it looked like overkill for what I wanted. Instead, I made this simple overload (down) to resize on the basis of items in the list.
I just tested to display in description mode on Windows Vista, but it is simple and works well.
Once #pragma // & lt; Summary & gt; /// A list view based control that adds a method to resize itself to show all its /// objects. /// & lt; / Summary & gt; Public Refine Class ResizingListView: Public System :: Windows :: Form :: List View {Public: /// & lt; Summary & gt; /// A ResizingListView /// & lt; / Summary & gt; ResizingListView (zero); /// & lt; Summary & gt; /// Excludes all the objects within the height and control of the header and / and changes itself again so that all the objects are shown. /// & lt; / Summary & gt; Zero ResizeToItems (zero) {// Header int headers work out the heights = 0; Int ItemHight = 0; If (this-> item-> calculates == 0) {// If there is no object present, add one so that we can use it to use - & gt; Item- & gt; Add (""); HeaderHeight = GetHeaderSize (); This- & gt; Things-> clean (); Itemhit = 0; } And {HeadHead = GetHeaderSize (); Itemhit = it- & gt; Item- & gt; Calculation * This-> Items [0] - & gt; Bounce.heat; } // Complete the overall height and resize it System :: Drawing :: Size sz = this-> Shape; Integer limit size = 0; If (this-> Frontline! = System :: Windows :: Form :: Border Style :: None) {borderSize = 2; } Sz.Height = headerHeight + itemsHeight + borderSize; It-> size = sz; } Conserved: /// & lt; Summary & gt; The /// list is located at the top of the first item, to see how long the /// header is. Note: At least one item _must_ or /// exception will be thrown in the list /// & lt; / Summary & gt; /// & lt; Returns & gt; Header height & lt; / Returns & gt; Int GetHeaderSize (zero) {return items [0] - & gt; Bounds. Top; }};
Comments
Post a Comment