버튼 이벤트 실행..
*
Public Class Form1
Dim mybutton As Button
Dim myText As TextBox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = 400
Me.Height = 210
Me.Text = "실행중 생성된 버튼 이벤트 실행"

For i As Integer = 1 To 5

mybutton = New Button
With mybutton
.Name = "Button" + i.ToString
.Text = "올려보세여"
.Top = 25 * i
.Left = 10
.Width = 100

AddHandler .MouseHover, AddressOf Button_MouseHover
Me.Controls.Add(mybutton)
End With
Next

myText = New TextBox
With myText
.Top = 25
.Left = 150
.Width = 200
.Height = 125
.Multiline = True
.ScrollBars = ScrollBars.Vertical
Me.Controls.Add(myText)
End With
End Sub

별도의 버튼 및 텍스트 박스를 설정할 필요는 없습니다.

그냥 폼에서 실행 시키시면 됩니다.

 

마지막 코드는 빼 놓았습니다.

맞춰 보세여. 

 

20140929_이벤트 실행.png

이 게시물을

댓글'1'
V닉맨
  • 2014.10.02
  • 수정: 2014.10.02 07:45:33

Public Class Form1
    Dim mybutton As Button
    Dim myText As TextBox

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.Width = 400
        Me.Height = 210
        Me.Text = "실행중 생성된 버튼 이벤트 실행"

        For i As Integer = 1 To 5
            mybutton = New Button
            With mybutton
                .Name = "Button" + i.ToString
                .Text = "올려보세요"
                .Top = 25 * i
                .Left = 10
                .Width = 100

                AddHandler .MouseHover, AddressOf Button_mousehover
                Me.Controls.Add(mybutton)
            End With
        Next

        myText = New TextBox
        With myText
            .Top = 25
            .Left = 150
            .Width = 200
            .Height = 125
            .Multiline = True
            .ScrollBars = ScrollBars.Vertical
            Me.Controls.Add(myText)
        End With
    End Sub

    Private Sub Button_MouseHover(sender As System.Object, e As System.EventArgs) Handles MyBase.MouseHover
        myText.Text &= "마우스는" & sender.name & "위에 있습니다" & vbCrLf
    End Sub
End Class

이 댓글을

공유하기

SEARCH

MENU NAVIGATION