Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

We were trying to create and destroy buttons in the usual way of a "control array" but it is too slow if trying to do about 100 buttons. Is there a better performing method than the standard way of doing it in vb.net?

 

I thought I remember something about bit something that might work. I forget what it's called. Thanks for the help.

Posted

Public Sub DoButtons(ByVal uplimit As Integer)
       Dim x As Integer
       Dim xx As Integer
       Dim y As Integer
       Dim mybutt As Button
       y = 5
       xx = 1
       For x = 1 To uplimit
           TheButs(x) = New System.Windows.Forms.Button
           TheButs(x).Size = New System.Drawing.Size(36, 36)
           TheButs(x).Font = New System.Drawing.Font("Microsoft Sans Serif", 6.75!, System.Drawing.FontStyle.Regular)
           xx += 1
           If xx > 10 Then xx -= 10
           Select Case x
               Case 11
                   y = 44
               Case 21
                   y = 83 '44 + 39
               Case 31
                   y = 122 '44 + 39 * 2
               Case 41
                   y = 161 '44 + 39 * 3
               Case 51
                   y = 200 '44 + 39 * 4
               Case 61
                   y = 239 '44 + 39 * 5
               Case 71
                   y = 278 '44 + 39 * 6
               Case 81
                   y = 317 '44 + 39 * 7
               Case 91
                   y = 356 '44 + 39 * 8
               Case 101
                   y = 356 '44 + 39 * 8
           End Select
           TheButs(x).Location = New System.Drawing.Point(y, 26 + ((xx - 1) * 38))
           TheButs(x).Text = x
           Me.Controls.Add(TheButs(x))
           AddHandler TheButs(x).Click, AddressOf ButtonsAll_Click
       Next x
   End Sub

That's the sub that creates the buttons.

 

       
For x = 1 To NumberofButtons
           TheButs(x).Visible = True
Next x

Sub that shows. Sub that hides is just that only with false obviously. I've tried show() and hide()

Posted

I'm running it on my laptop which is 1.6 Centrino.

 

I guess I should also add that this is being developed for a smart application so I'm running it in the ce.net emulator. Also, I stuck a msgbox at the end of the for next to show me the time and it hits the msgbox before it's done drawing the buttons. I don't think it's a code related issue, but more a factor of drawing the buttons. I'd say it takes about 1/2 a second, maybe a little more, to draw them.

 

I also tested by creating another button that hides and then shows the buttons and I get no delay whatsoever.

 

I also did some more research and found some other talk about .NET being slow to draw controls, especially over 50. I heard from somewhere, don't remember where, that you can use bitblt to help this somehow.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...