问题
i have a ListView set to Tileview. The ListView width is 300 and so is the tile width.
This works fine when the number of tiles does not overflow resulting in a scrollbar.
When it does overflow however, when the vertical scrollbar appears, a horizontal scrollbar also appears because the vertical scrollbar lowers the listview width for the tiles. Is there a way i can have the tiles autoresize to fill the listview?
See example image:
What currently happens:
What i want to happen:
I tried setting the width to 100% but that doesnt work. Any ideas?
回答1:
There is no direct way to detect that the scrollbar became visible. An indirect way though, write an event handler for the ClientSizeChanged event:
private void listView1_ClientSizeChanged(object sender, EventArgs e) {
listView1.TileSize = new Size(listView1.ClientSize.Width, listView1.TileSize.Height);
}
Also change the DPI setting on your machine to verify that your tile size is still appropriate. That normally changes the size of the controls. ClientSize.Width is your friend.
来源:https://stackoverflow.com/questions/4463774/c-sharp-listview-tile-width-100