VB.Net Tutorial/GUI/GroupBox — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
Add title to group box
Imports System.Windows.Forms
public class GroupTitle
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
"Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected 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.GroupBox1 = New System.Windows.Forms.GroupBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
"
"GroupBox1
"
Me.GroupBox1.Controls.Add(Me.Button2)
Me.GroupBox1.Controls.Add(Me.Button1)
Me.GroupBox1.Location = New System.Drawing.Point(12, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(369, 96)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Title"
"
"Button1
"
Me.Button1.Location = New System.Drawing.Point(44, 41)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
"
"Button2
"
Me.Button2.Location = New System.Drawing.Point(250, 41)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(75, 23)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Button2"
Me.Button2.UseVisualStyleBackColor = True
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(393, 122)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
End Class
Resize a group box
Imports System.Windows.Forms
public class FormResizeEvent
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
GroupBox1.Top = 0
GroupBox1.Left = 0
GroupBox1.Width = Me.Width
GroupBox1.Height = Me.Height
Label1.Left = GroupBox1.Top + 10
Label1.Top = GroupBox1.Left + 20
TextBox1.Top = Label1.Top + 50
TextBox1.Left = Label1.Left
TextBox1.Width = GroupBox1.Width - 20
End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
"Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected 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.GroupBox1 = New System.Windows.Forms.GroupBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
"
"GroupBox1
"
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Location = New System.Drawing.Point(12, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(392, 195)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "GroupBox1"
"
"TextBox1
"
Me.TextBox1.Location = New System.Drawing.Point(32, 62)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(331, 21)
Me.TextBox1.TabIndex = 5
"
"Label1
"
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(30, 30)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(41, 12)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Label1"
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(416, 219)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
End Class
Using GroupBoxes and Panels to hold buttons
Imports System.Windows.Forms
public class GroupBoxPanel
public Shared Sub Main
Application.Run(New FrmGroupBox)
End Sub
End class
Public Class FrmGroupBox
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
Friend WithEvents mainGroupBox As System.Windows.Forms.GroupBox
Private WithEvents mainPanel As System.Windows.Forms.Panel
Friend WithEvents cmdRight As System.Windows.Forms.Button
Friend WithEvents cmdHi As System.Windows.Forms.Button
Friend WithEvents cmdLeft As System.Windows.Forms.Button
Friend WithEvents cmdBye As System.Windows.Forms.Button
Friend WithEvents lblMessage As System.Windows.Forms.Label
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"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.cmdRight = New System.Windows.Forms.Button()
Me.cmdBye = New System.Windows.Forms.Button()
Me.mainPanel = New System.Windows.Forms.Panel()
Me.cmdLeft = New System.Windows.Forms.Button()
Me.cmdHi = New System.Windows.Forms.Button()
Me.lblMessage = New System.Windows.Forms.Label()
Me.mainGroupBox = New System.Windows.Forms.GroupBox()
Me.mainPanel.SuspendLayout()
Me.mainGroupBox.SuspendLayout()
Me.SuspendLayout()
"
"cmdRight
"
Me.cmdRight.Location = New System.Drawing.Point(352, 32)
Me.cmdRight.Name = "cmdRight"
Me.cmdRight.Size = New System.Drawing.Size(75, 40)
Me.cmdRight.TabIndex = 0
Me.cmdRight.Text = "Far Right"
"
"cmdBye
"
Me.cmdBye.Location = New System.Drawing.Point(112, 40)
Me.cmdBye.Name = "cmdBye"
Me.cmdBye.Size = New System.Drawing.Size(75, 40)
Me.cmdBye.TabIndex = 1
Me.cmdBye.Text = "Bye"
"
"mainPanel
"
Me.mainPanel.AutoScroll = True
Me.mainPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.mainPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdLeft, Me.cmdRight})
Me.mainPanel.Location = New System.Drawing.Point(40, 192)
Me.mainPanel.Name = "mainPanel"
Me.mainPanel.Size = New System.Drawing.Size(184, 112)
Me.mainPanel.TabIndex = 1
"
"cmdLeft
"
Me.cmdLeft.Location = New System.Drawing.Point(16, 32)
Me.cmdLeft.Name = "cmdLeft"
Me.cmdLeft.Size = New System.Drawing.Size(75, 40)
Me.cmdLeft.TabIndex = 1
Me.cmdLeft.Text = "Far Left"
"
"cmdHi
"
Me.cmdHi.Location = New System.Drawing.Point(16, 40)
Me.cmdHi.Name = "cmdHi"
Me.cmdHi.Size = New System.Drawing.Size(75, 40)
Me.cmdHi.TabIndex = 0
Me.cmdHi.Text = "Hi"
"
"lblMessage
"
Me.lblMessage.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblMessage.Location = New System.Drawing.Point(32, 136)
Me.lblMessage.Name = "lblMessage"
Me.lblMessage.Size = New System.Drawing.Size(200, 40)
Me.lblMessage.TabIndex = 2
Me.lblMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
"
"mainGroupBox
"
Me.mainGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdBye, Me.cmdHi})
Me.mainGroupBox.Location = New System.Drawing.Point(32, 16)
Me.mainGroupBox.Name = "mainGroupBox"
Me.mainGroupBox.TabIndex = 0
Me.mainGroupBox.TabStop = False
Me.mainGroupBox.Text = "Main GroupBox"
"
"FrmGroupBox
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(264, 333)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblMessage, Me.mainPanel, Me.mainGroupBox})
Me.Name = "FrmGroupBox"
Me.Text = "GroupBoxPanelExample"
Me.mainPanel.ResumeLayout(False)
Me.mainGroupBox.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub cmdHi_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdHi.Click
lblMessage.Text = "Hi pressed"
End Sub
Private Sub cmdBye_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdBye.Click
lblMessage.Text = "Bye pressed"
End Sub
Private Sub cmdLeft_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdLeft.Click
lblMessage.Text = "Far left pressed"
End Sub
Private Sub cmdRight_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdRight.Click
lblMessage.Text = "Far right pressed"
End Sub
End Class