How to scroll more smooth

  • Thread starter Thread starter peng12341
  • Start date Start date
P

peng12341

I've created an empty tabpage. At runtime i add lots of controls with
this function:

For i = 0 To mani_settings.count
Dim index
Dim label As New Label
label.Top = 12 + i * 26
label.Left = 8
label.AutoSize = True
label.Text = mani_settings.settings(i).name
index = labels_mani_settings.Add(label)

Me.TabPage2_Mani_Settings.Controls.Add(labels_mani_settings(index))
ToolTip1.SetToolTip(labels_mani_settings(index),
mani_settings.settings(i).description)
Dim textbox As New TextBox
textbox.Top = 12 + i * 26
textbox.Left = label.Width + 14
textbox.Width = Me.TabPage2_Mani_Settings.Width -
label.Width - 22
textbox.Height = 20
textbox.Text = mani_settings.settings(i).value
index = textboxes_mani_settings.Add(textbox)

Me.TabPage2_Mani_Settings.Controls.Add(textboxes_mani_settings(index))
ToolTip1.SetToolTip(textboxes_mani_settings(index),
mani_settings.settings(i).description)
Next

Now there are two problems. First if i scroll the tabpage it looks very
ugly. Because it doesen't repaint correctly. if i do a update() on the
form throug the onscrolling event of the tabpage it is better but not
perfect.

The second problem is that it takes about 10 seconds to create all
those controls. This is a bit slow, i think.

Do you now any solution to solve these two problems?

Thanks,

peng12341
 
Regarding the second problem:

Have you looked at the Control.SuspendLayout method in
the online help?

"When adding several controls to a parent control, it is recommended
that you call the SuspendLayout method before initializing the
controls to be added. After adding the controls to the parent control,
call the ResumeLayout method. This will increase the performance of
applications with many controls."

But perhaps you should replace the whole thing with a ListView or
grid control of some sort. I won't go into that as I have no idea what
kind of look you are striving for.

/JB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top