Hi,
I hope someone can help. If I create a large table, the display of the form is really bad, especially if I add grid lines. I get transparent holes where the controls should be and it takes a long time to draw. I made an example of this below. (Just cut and paste into an empty project).
I've tried everything I can think of, including freezing the form, suspend/resume, hiding the form, but I dont seem to be able to improve it at all. The dynamics of the display is so bad, I dont want to release the app.
Any help appreciated.
I hope someone can help. If I create a large table, the display of the form is really bad, especially if I add grid lines. I get transparent holes where the controls should be and it takes a long time to draw. I made an example of this below. (Just cut and paste into an empty project).
I've tried everything I can think of, including freezing the form, suspend/resume, hiding the form, but I dont seem to be able to improve it at all. The dynamics of the display is so bad, I dont want to release the app.
Any help appreciated.
VB.NET:
Public Class Form1
Dim t As New TableLayoutPanel
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Refresh()
Me.BackColor = SystemColors.Control
Me.TransparencyKey = System.Drawing.Color.Empty
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
Me.SetStyle(ControlStyles.UserPaint, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.SupportsTransparentBackColor, False)
Me.UpdateStyles()
Me.Width = 500
Me.Height = 400
Me.AutoSize = True
Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowOnly
Dim b As New Button
AddHandler b.Click, AddressOf BClick
Me.Controls.Add(b)
b.Location = New Point(0, 0)
b.Text = "+/- Grid"
b.Show()
b.BringToFront()
t.AutoSize = True
t.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
t.ColumnCount = 30
t.RowCount = 60
t.Dock = DockStyle.Fill
Me.Refresh()
Dim larray(1800) As Label
For i = 1 To larray.Length - 1
Dim l As New Label
l.AutoSize = True
l.Text = i.ToString
l.BackColor = Me.BackColor
larray(i) = l
Next
t.Controls.AddRange(larray)
Me.Controls.Add(t)
End Sub
Private Sub BClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
If t.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single Then
Me.Hide()
t.CellBorderStyle = TableLayoutPanelCellBorderStyle.None
Me.Show()
Else
Me.Hide()
t.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single
Me.Show()
End If
End Sub
End Class