开发者

Spacing problems in a ListView control

I have a st开发者_Python百科andard ListView control in a VB.Net Windows Forms project. The view is set to Tile. Users report that they see the following:

Spacing problems in a ListView control

Do you know how I could fix the problem? All the design work was done using VS 2010.


Yes, this will happen when you changed the list view's TileSize property and your program runs on a machine with a higher video DPI setting. That will make the fonts bigger. Causing the text to no longer fit the tile. Everything else is taken care of by the automatic scaling built into the Form class.

You should scale the tile size, making it bigger so that the text fits again. Make it look similar to this:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    MyBase.OnLoad(e)
    Using gr = Me.CreateGraphics
        Dim tile As New Size( _
          CInt(Me.ListView1.TileSize.Width * gr.DpiX / 96), _
          CInt(Me.ListView1.TileSize.Height * gr.DpiY / 96))
        ListView1.TileSize = tile
    End Using
End Sub

This assumes that you designed the form on a machine that has the default 96 dots per inch setting. Leave a bit of slack in the original tile size, the scaling isn't perfect due to TrueType hinting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜