moving large numbers of controls

I placed a large number of controls(label) on DataGridView, I moves them ( DGV cells & controls) by the scrollbar, but it works very slow. it's because i use for loop on all labels & move them separately. Is any other way to move these controls , maybe some way to group them ,but without lossing functionality of DGV?

there is Sub for scroling Labels on DGV Private Sub DGV_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles DGV.Scroll If e.NewValue e.OldValue Then For i = 0 To DGV.Controls.Count - 1 If TypeOf DGV.Controls.Item(i) Is Windows.Forms.Label Then If e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then DGV.Controls(i).Location = New System.Drawing.Point(DGV.Controls(i).Location.X + ((e.OldValue - e.NewValue)), DGV.Controls(i).Location.Y) Else DGV.Controls(i).Location = New System.Drawing.Point(DGV.Controls(i).Location.X, DGV.Controls(i).Location.Y + ((e.OldValue - e.NewValue) * 20)) End If End If Next i Application.DoEvents() If e.ScrollOrientation = ScrollOrientation.VerticalScroll Then For i = 0 To PanelPokoje.Controls.Count - 1 If TypeOf PanelPokoje.Controls.Item(i) Is Windows.Forms.Label Then PanelPokoje.Controls(i).Location = New System.Drawing.Point(PanelPokoje.Controls(i).Location.X, PanelPokoje.Controls(i).Location.Y + ((e.OldValue - e.NewValue) * 20)) End If Next i Application.DoEvents() Else For i = 0 To PanelDaty.Controls.Count - 1 If TypeOf PanelDaty.Controls.Item(i) Is Windows.Forms.Label Then PanelDaty.Controls(i).Location = New System.Drawing.Point(PanelDaty.Controls(i).Location.X + ((e.OldValue - e.NewValue)), PanelDaty.Controls(i).Location.Y) End If Next i Application.DoEvents() End If End If End Sub
Submitted byBzyQon Mon, 10/26/2009 - 04:15

I trying to do schedule with appointment displayed like in booking system, I want to be able to split cells of schedule on two parts( one for end of elary appointment, second one for beginning of next one). Do get that I’m using labels as appointments & DGV as a base. I’m using DGV to add appointment ( multi selecting ) . Labels are appointments with assigned events , to change or to delete them. After that I’m trying to scroll schedule & I get that slowly working scroll

Add new comment