
Question:
How can I add some extra space between the last item in a listview and the bottom of the control? I don't want to add an empty item to the bottom of the list.
Answer1:You can't do this directly. Unfortunately the styling options of ListView
are rather limited.
Unless you go for owner-drawing it.. Which is powerful and not very hard. But even there I doubt that the Items
can have different Heights
..
But there is a simple trick you can use:
Remove the LV's borders and place it inside a Panel
with appropriate borders. Dock
it there to Fill
the Panel and give the Panel a Padding
of maybe (0;0;0,10) and voila, the will always be a Padding
of 10 pixels that looks as if it belongs to the ListView
..
Instead of using the Designer, you could put these lines in the Form.Load
to make it work on startup:
Panel P = new Panel();
P.BackColor = listView1.BackColor;
P.Location = listView1.Location;
P.Size = listView1.Size;
P.Padding = new System.Windows.Forms.Padding(0,0,0,10);
P.BorderStyle = listView1.BorderStyle;
listView1.BorderStyle = BorderStyle.None;
listView1.Parent = P;
listView1.Dock = DockStyle.Fill;
this.Controls.Add(P);