VB.Net by API/System.Windows.Forms/Label
Содержание
- 1 Label.BorderStyle
- 2 Label.Click
- 3 Label.DataBindings.Add
- 4 Label.DoDragDrop
- 5 Label.DoubleClick
- 6 Label.DragDrop
- 7 Label.DragEnter
- 8 Label.Font.Size
- 9 Label.Font.Style
- 10 Label.ForeColor
- 11 Label.Image
- 12 Label.ImageAlign
- 13 Label.ImageIndex
- 14 Label.ImageList
- 15 Label.MouseDown
- 16 Label.MouseEnter
- 17 Label.MouseHover
- 18 Label.MouseLeave
- 19 Label.MouseMove
- 20 Label.MouseUp
- 21 Label.MouseWheel
- 22 Label.SetBounds
- 23 Label.Text
- 24 Label.TextAlign
- 25 Label.Visible
Label.BorderStyle
<source lang="vbnet"> 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.ruponentModel.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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.SuspendLayout() " "Label1 " Me.Label1.Location = New System.Drawing.Point(30, 30) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(150, 25) Me.Label1.TabIndex = 0 Me.Label1.Text = "No border" " "Label2 " Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label2.Location = New System.Drawing.Point(30, 80) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(150, 25) Me.Label2.TabIndex = 1 Me.Label2.Text = "Fixed Single Border" " "Label3 " Me.Label3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label3.Location = New System.Drawing.Point(30, 140) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(150, 25) Me.Label3.TabIndex = 2 Me.Label3.Text = "Fixed 3D Border" " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 197) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.Label2, Me.Label1}) Me.Name = "Form1" Me.Text = "LabelBorders" Me.ResumeLayout(False) End Sub
- End Region
End Class
</source>
Label.Click
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.DataBindings.Add
<source lang="vbnet"> Imports System Imports System.Data Imports System.Windows.Forms Imports System.Data.SqlClient public class MainClass
Shared Sub Main() Dim form1 As Form = New Form1 Application.Run(form1) End Sub
End Class
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.ruponentModel.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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents DataSet1 As System.Data.DataSet <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.DataSet1 = New System.Data.DataSet CType(Me.DataSet1, System.ruponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() " "Label1 " Me.Label1.Location = New System.Drawing.Point(16, 16) Me.Label1.Name = "Label1" Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" " "Label2 " Me.Label2.Location = New System.Drawing.Point(16, 56) Me.Label2.Name = "Label2" Me.Label2.TabIndex = 1 Me.Label2.Text = "Label2" " "DataSet1 " Me.DataSet1.DataSetName = "NewDataSet" Me.DataSet1.Locale = New System.Globalization.CultureInfo("en-GB") " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(128, 85) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" CType(Me.DataSet1, System.ruponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub
- End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load "Create Connection object Dim thisConnection As New SqlConnection _ ("server=(local)\SQLEXPRESS;" & _ "integrated security=sspi;" & _ "database=MyDatabase") " Sql Query Dim sql As String = _ "SELECT * FROM Employee" " Create Data Adapter Dim da As New SqlDataAdapter(sql, thisConnection) " Fill Dataset da.Fill(DataSet1, "Employee") " Bind Label1 to ProductName column of the Products table Label1.DataBindings.Add("text", DataSet1, "Employee.FirstName") " Bind Label2 to UnitPrice column of the Products table Label2.DataBindings.Add("text", DataSet1, "Employee.LastName") End Sub
End Class
</source>
Label.DoDragDrop
<source lang="vbnet"> Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms public class LabelDrag
public Shared Sub Main Application.Run(New Form1) End Sub
End class Public Class Form1
" Start a drag. Private Sub lblDragSource_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles lblDragSource.MouseDown lblDragSource.DoDragDrop("Here"s the drag data!", DragDropEffects.Copy) End Sub " Make sure the drag is coming from lblDragSource. Private Sub lblDropTarget_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles lblDropTarget.DragEnter e.Effect = DragDropEffects.Copy End Sub " Display the dropped data. Private Sub lblDropTarget_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles lblDropTarget.DragDrop MessageBox.Show(e.Data.GetData("Text").ToString) End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.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. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblDragSource = New System.Windows.Forms.Label Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout() " "lblDragSource " Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = New System.Drawing.Point(16, 16) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size(96, 64) Me.lblDragSource.TabIndex = 0 Me.lblDragSource.Text = "Drag Source" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter " "lblDropTarget " Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point(168, 16) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(96, 64) Me.lblDropTarget.TabIndex = 1 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(279, 95) Me.Controls.Add(Me.lblDropTarget) Me.Controls.Add(Me.lblDragSource) Me.Name = "Form1" Me.Text = "LabelDrag" Me.ResumeLayout(False) End Sub Friend WithEvents lblDragSource As System.Windows.Forms.Label Friend WithEvents lblDropTarget As System.Windows.Forms.Label
End Class
</source>
Label.DoubleClick
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.DragDrop
<source lang="vbnet"> Imports System Imports System.Runtime.InteropServices Imports System.Drawing Imports System.ruponentModel Imports System.Windows.Forms Imports System.IO Public Class MainClass
Shared Sub Main(ByVal args As String()) Dim myform As New Form1() Application.Run(myform) End Sub
End Class Public Class Form1
" Allow Copy if there is FileDrop data. Private Sub lblDropTarget_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblDropTarget.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub " Display the dropped file names. Private Sub lblDropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblDropTarget.DragDrop lstFiles.Items.Clear() Dim file_names As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String()) For Each file_name As String In file_names lstFiles.Items.Add(file_name) Next file_name End Sub
End Class <Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.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. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lstFiles = New System.Windows.Forms.ListBox Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout() " "lstFiles " Me.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill Me.lstFiles.FormattingEnabled = True Me.lstFiles.Location = New System.Drawing.Point(0, 48) Me.lstFiles.Name = "lstFiles" Me.lstFiles.Size = New System.Drawing.Size(274, 160) Me.lstFiles.TabIndex = 3 " "lblDropTarget " Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Dock = System.Windows.Forms.DockStyle.Top Me.lblDropTarget.Location = New System.Drawing.Point(0, 0) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(274, 48) Me.lblDropTarget.TabIndex = 2 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(274, 210) Me.Controls.Add(Me.lstFiles) Me.Controls.Add(Me.lblDropTarget) Me.Name = "Form1" Me.Text = "AcceptFiles" Me.ResumeLayout(False) End Sub Friend WithEvents lstFiles As System.Windows.Forms.ListBox Friend WithEvents lblDropTarget As System.Windows.Forms.Label
End Class
</source>
Label.DragEnter
<source lang="vbnet"> Imports System Imports System.Runtime.InteropServices Imports System.Drawing Imports System.ruponentModel Imports System.Windows.Forms Imports System.IO Public Class MainClass
Shared Sub Main(ByVal args As String()) Dim myform As New Form1() Application.Run(myform) End Sub
End Class Public Class Form1
" Allow Copy if there is FileDrop data. Private Sub lblDropTarget_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblDropTarget.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub " Display the dropped file names. Private Sub lblDropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblDropTarget.DragDrop lstFiles.Items.Clear() Dim file_names As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String()) For Each file_name As String In file_names lstFiles.Items.Add(file_name) Next file_name End Sub
End Class <Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.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. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lstFiles = New System.Windows.Forms.ListBox Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout() " "lstFiles " Me.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill Me.lstFiles.FormattingEnabled = True Me.lstFiles.Location = New System.Drawing.Point(0, 48) Me.lstFiles.Name = "lstFiles" Me.lstFiles.Size = New System.Drawing.Size(274, 160) Me.lstFiles.TabIndex = 3 " "lblDropTarget " Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Dock = System.Windows.Forms.DockStyle.Top Me.lblDropTarget.Location = New System.Drawing.Point(0, 0) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(274, 48) Me.lblDropTarget.TabIndex = 2 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(274, 210) Me.Controls.Add(Me.lstFiles) Me.Controls.Add(Me.lblDropTarget) Me.Name = "Form1" Me.Text = "AcceptFiles" Me.ResumeLayout(False) End Sub Friend WithEvents lstFiles As System.Windows.Forms.ListBox Friend WithEvents lblDropTarget As System.Windows.Forms.Label
End Class
</source>
Label.Font.Size
<source lang="vbnet">
Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class CheckBoxEvent
public Shared Sub Main Application.Run(New FrmCheckBox) End Sub
End class
Public Class FrmCheckBox
Inherits System.Windows.Forms.Form Friend WithEvents chkItalic As System.Windows.Forms.CheckBox Friend WithEvents lblOutput As System.Windows.Forms.Label Friend WithEvents chkBold As System.Windows.Forms.CheckBox Public Sub New() MyBase.New() Me.lblOutput = New System.Windows.Forms.Label() Me.chkItalic = New System.Windows.Forms.CheckBox() Me.chkBold = New System.Windows.Forms.CheckBox() Me.SuspendLayout() Me.lblOutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblOutput.Location = New System.Drawing.Point(48, 24) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(208, 24) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Watch the font style change" " "chkItalic " Me.chkItalic.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkItalic.Location = New System.Drawing.Point(152, 64) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size(64, 24) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" " "chkBold " Me.chkBold.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkBold.Location = New System.Drawing.Point(80, 64) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size(56, 24) Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" " "FrmCheckBox " Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(292, 117) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkItalic, Me.chkBold, Me.lblOutput}) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me.ResumeLayout(False) End Sub Private Sub chkItalic_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkItalic.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Italic) End Sub Private Sub chkBold_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkBold.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Bold) End Sub
End Class
</source>
Label.Font.Style
<source lang="vbnet">
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Drawing2D
public class CheckBoxEvent
public Shared Sub Main Application.Run(New FrmCheckBox) End Sub
End class
Public Class FrmCheckBox
Inherits System.Windows.Forms.Form Friend WithEvents chkItalic As System.Windows.Forms.CheckBox Friend WithEvents lblOutput As System.Windows.Forms.Label Friend WithEvents chkBold As System.Windows.Forms.CheckBox Public Sub New() MyBase.New() Me.lblOutput = New System.Windows.Forms.Label() Me.chkItalic = New System.Windows.Forms.CheckBox() Me.chkBold = New System.Windows.Forms.CheckBox() Me.SuspendLayout() Me.lblOutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblOutput.Location = New System.Drawing.Point(48, 24) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(208, 24) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Watch the font style change" " "chkItalic " Me.chkItalic.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkItalic.Location = New System.Drawing.Point(152, 64) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size(64, 24) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" " "chkBold " Me.chkBold.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.chkBold.Location = New System.Drawing.Point(80, 64) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size(56, 24) Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" " "FrmCheckBox " Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(292, 117) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkItalic, Me.chkBold, Me.lblOutput}) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me.ResumeLayout(False) End Sub Private Sub chkItalic_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkItalic.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Italic) End Sub Private Sub chkBold_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkBold.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Bold) End Sub
End Class
</source>
Label.ForeColor
<source lang="vbnet">
Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class UseColorDialogToSetLabelForeGroundColor
public Shared Sub Main Application.Run(New Form1) End Sub
End class Public Class Form1
Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub 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 Private components As System.ruponentModel.IContainer Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.ColorDialog1 = New System.Windows.Forms.ColorDialog Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() " "Button1 " Me.Button1.Location = New System.Drawing.Point(88, 152) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 32) Me.Button1.TabIndex = 1 Me.Button1.Text = "Change Color" " "Label1 " Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(72, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(120, 104) Me.Label1.TabIndex = 2 Me.Label1.Text = "www.vbex.ru" " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(256, 214) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Color Setting" Me.ResumeLayout(False) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ColorDialog1.ShowDialog() Label1.ForeColor = ColorDialog1.Color End Sub
End Class
</source>
Label.Image
<source lang="vbnet"> Imports System.Windows.Forms Imports System.Drawing Imports System.IO
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.ruponentModel.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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() " "Label1 " Me.Label1.Location = New System.Drawing.Point(20, 30) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(200, 150) Me.Label1.TabIndex = 0 " "Label2 " Me.Label2.Location = New System.Drawing.Point(20, 200) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(200, 150) Me.Label2.TabIndex = 1 " "Button1 " Me.Button1.Location = New System.Drawing.Point(280, 72) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 2 Me.Button1.Text = "Done" " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(408, 381) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.Label2, Me.Label1}) Me.Name = "Form1" Me.Text = "LabelImage" Me.ResumeLayout(False) End Sub
- End Region
Public Image1 As Image Public Image2 As Image Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Image1 = Image.FromFile("figure2.bmp") Label1.Image = Image1 Label2.Image = Image1 End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub
End Class
</source>
Label.ImageAlign
<source lang="vbnet"> imports System imports System.Drawing imports System.Windows.Forms public class ImageLists : inherits Form
dim imgList as ImageList = new ImageList() dim lbl as Label dim lnk as LinkLabel dim btn as Button dim nmbrUpDown as NumericUpDown public sub New() Size = new Size(300,300) dim img as Image dim i as integer dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"} for i = 0 to arFiles.Length - 1 img = Image.FromFile(arFiles(i)) imgList.Images.Add(img) next imgList.ImageSize = new Size(32, 32) img = Image.FromFile("5.ico") imgList.Images(imgList.Images.Count - 1) = img lbl = new Label() lbl.Parent = me lbl.Text = "Label" lbl.Location = new Point(0,0) lbl.Size = new Size (200,20) lbl.BorderStyle = BorderStyle.Fixed3D lbl.ImageList = imgList lbl.ImageIndex = 0 lbl.ImageAlign = ContentAlignment.MiddleRight " Create numeric updown to select the image nmbrUpDown = new NumericUpDown() nmbrUpDown.Parent = me nmbrUpDown.Location = new Point(0, 60) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged end sub public shared sub Main() Application.Run(new ImageLists()) end sub private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs) dim n as NumericUpDown = CType(sender, NumericUpDown) lbl.ImageIndex = CType(n.Value, Integer) end sub
end class
</source>
Label.ImageIndex
<source lang="vbnet"> imports System imports System.Drawing imports System.Windows.Forms public class ImageLists : inherits Form
dim imgList as ImageList = new ImageList() dim lbl as Label dim lnk as LinkLabel dim btn as Button dim nmbrUpDown as NumericUpDown public sub New() Size = new Size(300,300) dim img as Image dim i as integer dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"} for i = 0 to arFiles.Length - 1 img = Image.FromFile(arFiles(i)) imgList.Images.Add(img) next imgList.ImageSize = new Size(32, 32) img = Image.FromFile("5.ico") imgList.Images(imgList.Images.Count - 1) = img lbl = new Label() lbl.Parent = me lbl.Text = "Label" lbl.Location = new Point(0,0) lbl.Size = new Size (200,20) lbl.BorderStyle = BorderStyle.Fixed3D lbl.ImageList = imgList lbl.ImageIndex = 0 lbl.ImageAlign = ContentAlignment.MiddleRight " Create numeric updown to select the image nmbrUpDown = new NumericUpDown() nmbrUpDown.Parent = me nmbrUpDown.Location = new Point(0, 60) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged end sub public shared sub Main() Application.Run(new ImageLists()) end sub private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs) dim n as NumericUpDown = CType(sender, NumericUpDown) lbl.ImageIndex = CType(n.Value, Integer) end sub
end class
</source>
Label.ImageList
<source lang="vbnet">
imports System imports System.Drawing imports System.Windows.Forms public class ImageLists : inherits Form
dim imgList as ImageList = new ImageList() dim lbl as Label dim lnk as LinkLabel dim btn as Button dim nmbrUpDown as NumericUpDown public sub New() Size = new Size(300,300) dim img as Image dim i as integer dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"} for i = 0 to arFiles.Length - 1 img = Image.FromFile(arFiles(i)) imgList.Images.Add(img) next imgList.ImageSize = new Size(32, 32) img = Image.FromFile("5.ico") imgList.Images(imgList.Images.Count - 1) = img lbl = new Label() lbl.Parent = me lbl.Text = "Label" lbl.Location = new Point(0,0) lbl.Size = new Size (200,20) lbl.BorderStyle = BorderStyle.Fixed3D lbl.ImageList = imgList lbl.ImageIndex = 0 lbl.ImageAlign = ContentAlignment.MiddleRight " Create numeric updown to select the image nmbrUpDown = new NumericUpDown() nmbrUpDown.Parent = me nmbrUpDown.Location = new Point(0, 60) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged end sub public shared sub Main() Application.Run(new ImageLists()) end sub private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs) dim n as NumericUpDown = CType(sender, NumericUpDown) lbl.ImageIndex = CType(n.Value, Integer) end sub
end class
</source>
Label.MouseDown
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseEnter
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseHover
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseLeave
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseMove
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseUp
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.MouseWheel
<source lang="vbnet">
Option Strict On imports System imports System.Drawing imports System.Windows.Forms public class MouseEvents : inherits Form
private lbl as Label private WithEvents btnReset as Button public sub New() Size = new Size(400,600) btnReset = new Button() btnReset.Parent = me btnReset.Location = new Point(250,50) btnReset.Text = "Reset" lbl = new Label() lbl.Parent = me lbl.Location = new Point(50,50) lbl.Size = new Size(250,250) lbl.BorderStyle = BorderStyle.Fixed3D AddHandler lbl.MouseEnter, AddressOf lbl_MouseEnter AddHandler lbl.MouseHover, AddressOf lbl_MouseHover AddHandler lbl.MouseLeave, AddressOf lbl_MouseLeave AddHandler lbl.MouseDown, AddressOf lbl_MouseDown AddHandler lbl.MouseMove, AddressOf lbl_MouseMove AddHandler lbl.MouseUp, AddressOf lbl_MouseUp AddHandler lbl.MouseWheel, AddressOf lbl_MouseWheel AddHandler lbl.Click, AddressOf lbl_Click AddHandler lbl.DoubleClick, AddressOf lbl_DoubleClick end sub public shared sub Main() Application.Run(new MouseEvents()) end sub private sub btnReset_Click(ByVal sender as object, _ ByVal e as EventArgs) _ Handles btnReset.Click lbl.Text = "" end sub private sub lbl_MouseEnter(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseEnter" Console.WriteLine("Label MouseEnter") end sub private sub lbl_MouseHover(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseHover" Console.WriteLine("Label MouseHover") end sub private sub lbl_MouseLeave(ByVal sender as object, _ ByVal e as EventArgs) lbl.Text = "MouseLeave" Console.WriteLine("Label MouseLeave") end sub private sub lbl_MouseDown(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseDown" Console.WriteLine("Label MouseDown") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseMove(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseMove" Console.WriteLine("Label MouseMove") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseUp(ByVal sender as object, _ ByVal e as MouseEventArgs) lbl.Text = "MouseUp" Console.WriteLine("Label MouseUp") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_MouseWheel(ByVal sender as object,ByVal e as MouseEventArgs) lbl.Text = "MouseWheel" Console.WriteLine("Label MouseWheel") Console.WriteLine("Button: " + e.Button.ToString()) Console.WriteLine("Clicks: " + e.Clicks.ToString()) Console.WriteLine("Delta: " + e.Delta.ToString()) Console.WriteLine("X: " + e.X.ToString()) Console.WriteLine("Y: " + e.Y.ToString()) end sub private sub lbl_Click(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "Click" Console.WriteLine("Label Click") end sub private sub lbl_DoubleClick(ByVal sender as object,ByVal e as EventArgs) lbl.Text = "DoubleClick" Console.WriteLine("Label DoubleClick") end sub protected overrides sub OnMouseEnter(ByVal e as EventArgs) myBase.OnMouseEnter(e) Console.WriteLine("Form MouseEnter") end sub protected overrides sub OnMouseHover(ByVal e as EventArgs) myBase.OnMouseHover(e) Console.WriteLine("Form MouseHover") end sub protected overrides sub OnMouseLeave(ByVal e as EventArgs) myBase.OnMouseLeave(e) Console.WriteLine("Form MouseLeave") end sub
end class
</source>
Label.SetBounds
<source lang="vbnet"> Imports System Imports System.ruponentModel Imports System.Windows.Forms Imports System.Data Imports System.Configuration Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Drawing.Text Imports System.Globalization Imports System.Text Imports System.Collections Public Class MainClass
Shared Sub Main() Dim myform As Form = New Form1() Application.Run(myform) End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim lbl As New Label lbl.SetBounds(10, 50, 100, 25) lbl.Text = "Hello World!" Me.Controls.Add(lbl) End Sub
End Class <Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.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. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub
End Class
</source>
Label.Text
<source lang="vbnet"> 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.ruponentModel.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 Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.SuspendLayout() " "Button1 " Me.Button1.Location = New System.Drawing.Point(16, 184) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Date" " "Button2 " Me.Button2.Location = New System.Drawing.Point(112, 184) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 1 Me.Button2.Text = "Time" " "Button3 " Me.Button3.Location = New System.Drawing.Point(208, 184) Me.Button3.Name = "Button3" Me.Button3.TabIndex = 2 Me.Button3.Text = "Clear" " "Label1 " Me.Label1.Location = New System.Drawing.Point(30, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(150, 20) Me.Label1.TabIndex = 3 " "Label2 " Me.Label2.Location = New System.Drawing.Point(30, 90) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(150, 20) Me.Label2.TabIndex = 4 " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(304, 269) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.Button3, Me.Button2, Me.Button1}) Me.Name = "Form1" Me.Text = "DynamicLabels" Me.ResumeLayout(False) End Sub
- End Region
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = "Date: " & Now.Date Label1.Visible = True End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Label2.Text = "Time: " & Now.TimeOfDay.ToString() Label2.Visible = True End Sub Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click Label1.Visible = False Label2.Visible = False End Sub
End Class
</source>
Label.TextAlign
<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class TextAlignLabel
public Shared Sub Main Application.Run(New Form1) End Sub
End class 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.ruponentModel.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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents Label9 As System.Windows.Forms.Label Friend WithEvents Label10 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label9 = New System.Windows.Forms.Label Me.Label10 = New System.Windows.Forms.Label Me.SuspendLayout() " "Label1 " Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label1.Location = New System.Drawing.Point(16, 56) Me.Label1.Name = "Label1" Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" " "Label2 " Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label2.Location = New System.Drawing.Point(136, 56) Me.Label2.Name = "Label2" Me.Label2.TabIndex = 1 Me.Label2.Text = "Label2" Me.Label2.TextAlign = System.Drawing.ContentAlignment.TopCenter " "Label3 " Me.Label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label3.Location = New System.Drawing.Point(256, 56) Me.Label3.Name = "Label3" Me.Label3.TabIndex = 2 Me.Label3.Text = "Label3" Me.Label3.TextAlign = System.Drawing.ContentAlignment.TopRight " "Label4 " Me.Label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label4.Location = New System.Drawing.Point(16, 112) Me.Label4.Name = "Label4" Me.Label4.TabIndex = 3 Me.Label4.Text = "Label4" Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft " "Label5 " Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label5.Location = New System.Drawing.Point(136, 112) Me.Label5.Name = "Label5" Me.Label5.TabIndex = 4 Me.Label5.Text = "Label5" Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter " "Label6 " Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label6.Location = New System.Drawing.Point(256, 112) Me.Label6.Name = "Label6" Me.Label6.TabIndex = 5 Me.Label6.Text = "Label6" Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight " "Label7 " Me.Label7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label7.Location = New System.Drawing.Point(16, 168) Me.Label7.Name = "Label7" Me.Label7.TabIndex = 6 Me.Label7.Text = "Label7" Me.Label7.TextAlign = System.Drawing.ContentAlignment.BottomLeft " "Label8 " Me.Label8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label8.Location = New System.Drawing.Point(136, 168) Me.Label8.Name = "Label8" Me.Label8.TabIndex = 7 Me.Label8.Text = "Label8" Me.Label8.TextAlign = System.Drawing.ContentAlignment.BottomCenter " "Label9 " Me.Label9.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Label9.Location = New System.Drawing.Point(256, 168) Me.Label9.Name = "Label9" Me.Label9.TabIndex = 8 Me.Label9.Text = "Label9" Me.Label9.TextAlign = System.Drawing.ContentAlignment.BottomRight " "Label10 " Me.Label10.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label10.Location = New System.Drawing.Point(0, 0) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size(192, 48) Me.Label10.TabIndex = 9 Me.Label10.Text = "Labels" " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(376, 229) Me.Controls.Add(Me.Label10) Me.Controls.Add(Me.Label9) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub
- End Region
End Class
</source>
Label.Visible
<source lang="vbnet"> 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.ruponentModel.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 Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.SuspendLayout() " "Button1 " Me.Button1.Location = New System.Drawing.Point(16, 184) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Date" " "Button2 " Me.Button2.Location = New System.Drawing.Point(112, 184) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 1 Me.Button2.Text = "Time" " "Button3 " Me.Button3.Location = New System.Drawing.Point(208, 184) Me.Button3.Name = "Button3" Me.Button3.TabIndex = 2 Me.Button3.Text = "Clear" " "Label1 " Me.Label1.Location = New System.Drawing.Point(30, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(150, 20) Me.Label1.TabIndex = 3 " "Label2 " Me.Label2.Location = New System.Drawing.Point(30, 90) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(150, 20) Me.Label2.TabIndex = 4 " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(304, 269) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.Button3, Me.Button2, Me.Button1}) Me.Name = "Form1" Me.Text = "DynamicLabels" Me.ResumeLayout(False) End Sub
- End Region
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = "Date: " & Now.Date Label1.Visible = True End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Label2.Text = "Time: " & Now.TimeOfDay.ToString() Label2.Visible = True End Sub Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click Label1.Visible = False Label2.Visible = False End Sub
End Class
</source>