我有两个组合框,每组都有一个文本框。第三个文本框放在两个组框之外。
按钮1是表单加载时的默认接受按钮。
单击按钮1(或按下输入键)时,我需要按钮2成为默认接受按钮。
按钮3成为默认接受按钮,而不是按钮2,尽管我的代码。
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GroupBox1.Enabled = True
GroupBox2.Enabled = False
Me.AcceptButton = Button1
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("Button 1 pressed!")
GroupBox1.Enabled = False
GroupBox2.Enabled = True
Me.AcceptButton = Button2
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MessageBox.Show("Button 2 pressed!")
GroupBox1.Enabled = True
GroupBox2.Enabled = False
Me.AcceptButton = Button1
End Sub
End Class
答案 0 :(得分:2)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("Button 1 pressed!")
GroupBox1.Enabled = False
GroupBox2.Enabled = True
Me.AcceptButton = Button2
Button2.Focus()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MessageBox.Show("Button 2 pressed!")
GroupBox1.Enabled = True
GroupBox2.Enabled = False
Me.AcceptButton = Button1
Button1.Focus()
End Sub