C# ListView Tile Width 100%?

烂漫一生 提交于 2019-12-05 05:53:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!