VB.Net/GUI/Layout — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:43, 26 мая 2010
Get Frame Client Area Rectangle and layout Components
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 Object, _
ByVal e As System.EventArgs) Handles Me.Load
ArrangeTextBoxes()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Resize
ArrangeTextBoxes()
End Sub
Private Sub ArrangeTextBoxes()
Dim wid As Integer = Me.ClientRectangle.Width
Dim hgt1 As Integer = Me.ClientRectangle.Height \ 2
Dim hgt2 As Integer = Me.ClientRectangle.Height - hgt1
TextBox1.SetBounds(0, 0, wid, hgt1)
TextBox2.SetBounds(0, hgt1, wid, hgt2)
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 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.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
"
"TextBox1
"
Me.TextBox1.Location = New System.Drawing.Point(32, 40)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(72, 48)
Me.TextBox1.TabIndex = 0
"
"TextBox2
"
Me.TextBox2.Location = New System.Drawing.Point(152, 40)
Me.TextBox2.Multiline = True
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(72, 48)
Me.TextBox2.TabIndex = 1
"
"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.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Divide Form"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
End Class
Layout component your self
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Configuration
Imports System.Resources
Public Class GridForm
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 button4 As System.Windows.Forms.Button
Friend WithEvents button5 As System.Windows.Forms.Button
Friend WithEvents button6 As System.Windows.Forms.Button
Friend WithEvents button7 As System.Windows.Forms.Button
Friend WithEvents button8 As System.Windows.Forms.Button
Friend WithEvents button9 As System.Windows.Forms.Button
<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.button4 = New System.Windows.Forms.Button()
Me.button5 = New System.Windows.Forms.Button()
Me.button6 = New System.Windows.Forms.Button()
Me.button7 = New System.Windows.Forms.Button()
Me.button8 = New System.Windows.Forms.Button()
Me.button9 = New System.Windows.Forms.Button()
Me.SuspendLayout()
"
"button1
"
Me.button1.Location = New System.Drawing.Point(8, 8)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(75, 75)
Me.button1.TabIndex = 7
Me.button1.Text = "1"
"
"button2
"
Me.button2.Location = New System.Drawing.Point(88, 8)
Me.button2.Name = "button2"
Me.button2.Size = New System.Drawing.Size(75, 75)
Me.button2.TabIndex = 6
Me.button2.Text = "2"
"
"button3
"
Me.button3.Location = New System.Drawing.Point(168, 8)
Me.button3.Name = "button3"
Me.button3.Size = New System.Drawing.Size(75, 75)
Me.button3.TabIndex = 9
Me.button3.Text = "3"
"
"button4
"
Me.button4.Location = New System.Drawing.Point(8, 88)
Me.button4.Name = "button4"
Me.button4.Size = New System.Drawing.Size(75, 75)
Me.button4.TabIndex = 8
Me.button4.Text = "4"
"
"button5
"
Me.button5.Location = New System.Drawing.Point(88, 88)
Me.button5.Name = "button5"
Me.button5.Size = New System.Drawing.Size(75, 75)
Me.button5.TabIndex = 5
Me.button5.Text = "5"
"
"button6
"
Me.button6.Location = New System.Drawing.Point(168, 88)
Me.button6.Name = "button6"
Me.button6.Size = New System.Drawing.Size(75, 75)
Me.button6.TabIndex = 2
Me.button6.Text = "6"
"
"button7
"
Me.button7.Location = New System.Drawing.Point(8, 168)
Me.button7.Name = "button7"
Me.button7.Size = New System.Drawing.Size(75, 75)
Me.button7.TabIndex = 1
Me.button7.Text = "7"
"
"button8
"
Me.button8.Location = New System.Drawing.Point(88, 168)
Me.button8.Name = "button8"
Me.button8.Size = New System.Drawing.Size(75, 75)
Me.button8.TabIndex = 4
Me.button8.Text = "8"
"
"button9
"
Me.button9.Location = New System.Drawing.Point(168, 168)
Me.button9.Name = "button9"
Me.button9.Size = New System.Drawing.Size(75, 75)
Me.button9.TabIndex = 3
Me.button9.Text = "9"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(248, 246)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button1, Me.button2, Me.button3, Me.button4, Me.button5, Me.button6, Me.button7, Me.button8, Me.button9})
Me.Name = "Form1"
Me.Text = "Grid Layout Example"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub GridForm_Layout(ByVal sender As Object, ByVal e As System.Windows.Forms.LayoutEventArgs) Handles MyBase.Layout
Dim buttons As Button() = New Button() {button1, button2, button3, button4, button5, button6, button7, button8, button9}
Dim cx As Integer = ClientRectangle.Width / 3
Dim cy As Integer = ClientRectangle.Height / 3
Dim row As Integer = 0
Do While row < 3
Dim col As Integer = 0
Do While col < 3
Dim b As Button = buttons(col * 3 + row)
b.SetBounds(cx * row, cy * col, cx, cy)
col = col + 1
Loop
row = row + 1
Loop
SetClientSizeCore(cx * 3, cy * 3)
End Sub
Shared Sub Main()
Dim myform As Form = New GridForm()
Application.Run(myform)
End Sub
End Class
Table Layout
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Data.SqlClient
public class MainClass
Shared Sub Main()
Dim form1 As Form = New Form1
Application.Run(form1)
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.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel
Me.Label1 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.ruboBox1 = New System.Windows.Forms.ruboBox
Me.TableLayoutPanel1.SuspendLayout()
Me.SuspendLayout()
"
"TableLayoutPanel1
"
Me.TableLayoutPanel1.AutoSize = True
Me.TableLayoutPanel1.ColumnCount = 2
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80.0!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 192.0!))
Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Label7, 0, 1)
Me.TableLayoutPanel1.Controls.Add(Me.Label2, 0, 2)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox4, 1, 1)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox1, 1, 2)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox3, 1, 3)
Me.TableLayoutPanel1.Controls.Add(Me.Label3, 0, 3)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox2, 1, 4)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox5, 1, 6)
Me.TableLayoutPanel1.Controls.Add(Me.Label5, 0, 5)
Me.TableLayoutPanel1.Controls.Add(Me.Label8, 0, 4)
Me.TableLayoutPanel1.Controls.Add(Me.Label6, 0, 6)
Me.TableLayoutPanel1.Controls.Add(Me.ruboBox1, 1, 5)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(7, 7)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 7
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle)
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(272, 182)
Me.TableLayoutPanel1.TabIndex = 1
"
"Label1
"
Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.TableLayoutPanel1.SetColumnSpan(Me.Label1, 2)
Me.Label1.Location = New System.Drawing.Point(36, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(200, 20)
Me.Label1.TabIndex = 37
Me.Label1.Text = "Employee"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
"
"Label7
"
Me.Label7.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(11, 23)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(57, 13)
Me.Label7.TabIndex = 38
Me.Label7.Text = "First Name"
"
"Label2
"
Me.Label2.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(11, 43)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(58, 13)
Me.Label2.TabIndex = 40
Me.Label2.Text = "Last Name"
"
"TextBox4
"
Me.TextBox4.Anchor = System.Windows.Forms.AnchorStyles.None
Me.TextBox4.Location = New System.Drawing.Point(83, 23)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(186, 20)
Me.TextBox4.TabIndex = 0
"
"TextBox1
"
Me.TextBox1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.TextBox1.Location = New System.Drawing.Point(83, 43)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(186, 20)
Me.TextBox1.TabIndex = 1
"
"TextBox3
"
Me.TextBox3.Anchor = System.Windows.Forms.AnchorStyles.None
Me.TextBox3.Location = New System.Drawing.Point(83, 63)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(186, 20)
Me.TextBox3.TabIndex = 2
"
"Label3
"
Me.Label3.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(22, 63)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(35, 13)
Me.Label3.TabIndex = 42
Me.Label3.Text = "Street"
"
"TextBox2
"
Me.TextBox2.Anchor = System.Windows.Forms.AnchorStyles.None
Me.TextBox2.Location = New System.Drawing.Point(83, 83)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(186, 20)
Me.TextBox2.TabIndex = 3
"
"TextBox5
"
Me.TextBox5.Anchor = System.Windows.Forms.AnchorStyles.None
Me.TextBox5.Location = New System.Drawing.Point(144, 141)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(64, 20)
Me.TextBox5.TabIndex = 5
"
"Label5
"
Me.Label5.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(24, 103)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(32, 13)
Me.Label5.TabIndex = 46
Me.Label5.Text = "State"
"
"Label8
"
Me.Label8.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(28, 83)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(24, 13)
Me.Label8.TabIndex = 51
Me.Label8.Text = "City"
"
"Label6
"
Me.Label6.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(29, 144)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(22, 13)
Me.Label6.TabIndex = 52
Me.Label6.Text = "Zip"
"
"ComboBox1
"
Me.ruboBox1.Anchor = System.Windows.Forms.AnchorStyles.None
Me.ruboBox1.FormattingEnabled = True
Me.ruboBox1.Location = New System.Drawing.Point(152, 103)
Me.ruboBox1.Name = "ComboBox1"
Me.ruboBox1.Size = New System.Drawing.Size(48, 21)
Me.ruboBox1.TabIndex = 54
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(287, 197)
Me.Controls.Add(Me.TableLayoutPanel1)
Me.Name = "Form1"
Me.Text = "UseTableLayoutPanel"
Me.TableLayoutPanel1.ResumeLayout(False)
Me.TableLayoutPanel1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ruboBox
End Class