本文整理汇总了VB.NET中System.Windows.Forms.Form.Activated事件的典型用法代码示例。如果您正苦于以下问题:VB.NET Form.Activated事件的具体用法?VB.NET Form.Activated怎么用?VB.NET Form.Activated使用的例子?那么, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.Activated事件的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1:
Shared x As Integer = 200
Shared y As Integer = 200
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Create a new Form1 and set its Visible property to true.
Dim form2 As New Form1
form2.Visible = True
' Set the new form's desktop location so it appears below and
' to the right of the current form.
form2.SetDesktopLocation(x, y)
x += 30
y += 30
' Keep the current form active by calling the Activate method.
Me.Activate()
Me.Button1.Enabled = False
End Sub
' Updates the label text to reflect the current values of x and y,
' which was were incremented in the Button1 control's click event.
Private Sub Form1_Activated(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
Label1.Text = "x: " & x & " y: " & y
Label2.Text = "Number of forms currently open: " & count
End Sub
Shared count As Integer = 0
Private Sub Form1_Closed(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Closed
count -= 1
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
count += 1
End Sub
示例2: Module1
' 导入命名空间
Imports System.Windows.Forms
Module Module1
Sub Main()
Application.Run(New Form1)
End Sub
End Module
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
Friend WithEvents TabPage4 As System.Windows.Forms.TabPage
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TabPage2 = New System.Windows.Forms.TabPage()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.TabPage3 = New System.Windows.Forms.TabPage()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.TabPage4 = New System.Windows.Forms.TabPage()
Me.TextBox4 = New System.Windows.Forms.TextBox()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.TabPage2.SuspendLayout()
Me.TabPage3.SuspendLayout()
Me.TabPage4.SuspendLayout()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabPage1, Me.TabPage2, Me.TabPage3, Me.TabPage4})
Me.TabControl1.Location = New System.Drawing.Point(48, 48)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(288, 200)
Me.TabControl1.TabIndex = 0
'
'TabPage1
'
Me.TabPage1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1})
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(280, 174)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Visual Basic .Net"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(264, 160)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'TabPage2
'
Me.TabPage2.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox2})
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(280, 174)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "C# "
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(8, 8)
Me.TextBox2.Multiline = True
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(264, 160)
Me.TextBox2.TabIndex = 0
Me.TextBox2.Text = ""
'
'TabPage3
'
Me.TabPage3.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox3})
Me.TabPage3.Location = New System.Drawing.Point(4, 22)
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Size = New System.Drawing.Size(280, 174)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Text = "HTML"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(8, 8)
Me.TextBox3.Multiline = True
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(264, 160)
Me.TextBox3.TabIndex = 0
Me.TextBox3.Text = ""
'
'TabPage4
'
Me.TabPage4.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox4})
Me.TabPage4.Location = New System.Drawing.Point(4, 22)
Me.TabPage4.Name = "TabPage4"
Me.TabPage4.Size = New System.Drawing.Size(280, 174)
Me.TabPage4.TabIndex = 3
Me.TabPage4.Text = "Upgrading"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(8, 8)
Me.TextBox4.Multiline = True
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(264, 160)
Me.TextBox4.TabIndex = 0
Me.TextBox4.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(528, 389)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabControl1})
Me.Name = "Form1"
Me.Text = "TabControlDemo"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage2.ResumeLayout(False)
Me.TabPage3.ResumeLayout(False)
Me.TabPage4.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
TextBox1.Text = "some text"
TextBox2.Text = "some text"
TextBox3.Text = "some text"
TextBox4.Text = "some text"
End Sub
End Class