I'm adding (and removing) controls from a FlowLayoutPanel
and am noticing some serious levels of flickering. I've attempted to cover the FlowLayoutPanel
with a Panel
with "Loading" written on it, but the controls are loaded before the Panel
is displayed, so it is still visible.
Here's the code I'm using (Comments are in the code):
Private Sub ViewOrders_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Panel2.BringToFront() 'This covers the FlowLayoutPanel in which the custom controls are added
dgvViewOrders.DataSource = dtOrders
For i = 0 To dgvViewOrders.Columns.Count - 1
dgvViewOrders.Columns(i).Visible = False
Next
dgvViewOrders.Columns(0).Visible = True
dgvViewOrders.Columns(2).Visible = True
dgvViewOrders.Columns(10).Visible = True
dgvViewOrders.Columns(12).Visible = True
dgvViewOrders.Columns(12).DisplayIndex = 1
dgvViewOrders.Columns(2).DisplayIndex = 2
dgvViewOrders.Columns(10).HeaderText = "£ Total"
dgvViewOrders.Columns(12).HeaderText = "Date/Time"
CreateSecondPOC(Nothing, Nothing) 'This creates the custom controls
If dgvViewOrders.RowCount > 0 Then
dgvViewOrders.ClearSelection()
dgvViewOrders.CurrentCell = dgvViewOrders.Rows(0).Cells(0)
dgvViewOrders.Rows(0).Selected = True
End If
LoadingComplete = True
Panel2.SendToBack() 'Hide Panel so custom controls can be used
End Sub
I've also attempted something very similar using a BackgroundWorker
but it had the same effect.
Surely there's an easy approach to this that I am missing?