Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> button.Select

button.Select

From: hexathioorthooxalate <ruler_at_REMOVESPAM.clara.co.uk>
Date: Sun, 2 Nov 2003 15:13:20 -0000
Message-ID: <1067786005.39716.0@damia.uk.clara.net>


All, I appear to have a mind block at the moment. Could someone help me out and get me over this hurdle.

  1. Create a new VB.Net 2003 project with form1 open.
  2. Drop a "button1" onto the form.
  3. Paste in the code below.

When repeatNo is 0, I see the 6th button selected as expected. When repeatNo is >0, it isn't. For goodness sakes, why?

Thank you
Hexathioorthooxalate

Public Class Form1

    Inherits System.Windows.Forms.Form

'+ Windows Form Designer generated code

    Private Class btnExtend

        Inherits Button
    End Class

    Private Sub clearButtons()

        For Each o As Object In Me.Controls
            If TypeOf o Is btnExtend Then Me.Controls.Remove(o)
        Next

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, _

              ByVal e As System.EventArgs) Handles Button1.Click
        Dim btn As Button
        For repeatNo As Integer = 0 To 5
            clearButtons()
            For buttonCounter As Integer = 0 To 9
                btn = New Button
                btn.Size = New Size(10, 10)
                btn.Top = 20
                btn.Left = buttonCounter * 15
                Me.Controls.Add(btn)
                If buttonCounter = 5 Then btn.Select()
            Next buttonCounter
            MsgBox("complete" + repeatNo.ToString())
        Next repeatNo

    End Sub
End Class Received on Sun Nov 02 2003 - 09:13:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US