Imports System Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Windows.FormsNamespace Microsoft.Samples.Windows.Forms.VB.UpDownCtl
Public Class UpDownCtl Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
UpDownCtl = Me
'This call is required by the Windows Forms Designer. InitializeComponent()
'TOD Add any initialization after the InitializeComponent() call
'Complete intialization of the Form Me.updnTextAlign.Items.Add(New StringIntObject("Center", CInt(HorizontalAlignment.Center))) Me.updnTextAlign.Items.Add(New StringIntObject("Left", CInt(HorizontalAlignment.Left))) Me.updnTextAlign.Items.Add(New StringIntObject("Right", CInt(HorizontalAlignment.Right))) Me.updnTextAlign.SelectedIndex = 1
Me.updnUpDownAlignment.Items.Add(New StringIntObject("Left", CInt(LeftRightAlignment.Left))) Me.updnUpDownAlignment.Items.Add(New StringIntObject("Right", CInt(LeftRightAlignment.Right))) Me.updnUpDownAlignment.SelectedIndex = 1
Me.domainUpDown1.Items.Add("King Kong") Me.domainUpDown1.Items.Add("The Creature from the Black Lagoon") Me.domainUpDown1.Items.Add("Dracula") Me.domainUpDown1.Items.Add("Frankenstein's Monster") Me.domainUpDown1.Items.Add("Godzilla") Me.domainUpDown1.SelectedIndex = 0
Me.updnDecimalPlaces.DecimalPlaces = 0 End Sub
Public Overloads Overrides Sub Dispose() MyBase.Dispose() components.Dispose() End Sub
Private Sub updnUpDownAlignment_SelectedItemChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updnUpDownAlignment.SelectedItemChanged If updnUpDownAlignment.SelectedIndex <> -1 Then Dim sio As StringIntObject = CType(updnUpDownAlignment.Items(updnUpDownAlignment.SelectedIndex), StringIntObject) numericUpDown1.UpDownAlign = CType(sio.i, LeftRightAlignment) domainUpDown1.UpDownAlign = CType(sio.i, LeftRightAlignment) End If End Sub
Private Sub updnTextAlign_SelectedItemChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updnTextAlign.SelectedItemChanged If updnTextAlign.SelectedIndex <> -1 Then Dim sio As StringIntObject = CType(updnTextAlign.Items(updnTextAlign.SelectedIndex), StringIntObject) numericUpDown1.TextAlign = CType(sio.i, HorizontalAlignment) domainUpDown1.TextAlign = CType(sio.i, HorizontalAlignment) End If End Sub
Private Sub chkInterceptArrowKeys_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkInterceptArrowKeys.CheckedChanged numericUpDown1.InterceptArrowKeys = chkInterceptArrowKeys.Checked domainUpDown1.InterceptArrowKeys = chkInterceptArrowKeys.Checked End Sub
Private Sub chkSorted_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkSorted.CheckedChanged domainUpDown1.Sorted = chkSorted.Checked End Sub
Private Sub chkWrap_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkWrap.CheckedChanged domainUpDown1.Wrap = chkWrap.Checked End Sub
Private Sub updnIncrement_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updnIncrement.ValueChanged numericUpDown1.Increment = updnIncrement.Value End Sub
Private Sub updnDecimalPlaces_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updnDecimalPlaces.ValueChanged numericUpDown1.DecimalPlaces = CInt(updnDecimalPlaces.Value) updnIncrement.Value = CInt(updnIncrement.Value) ' Just so we don't increment by amounts we can't see. updnIncrement.DecimalPlaces = CInt(updnDecimalPlaces.Value) End Sub
#Region " Windows Form Designer generated code "
'Required by the Windows Form Designer Private components As System.ComponentModel.Container Protected WithEvents updnUpDownAlignment As System.Windows.Forms.DomainUpDown Protected WithEvents updnTextAlign As System.Windows.Forms.DomainUpDown Protected WithEvents lblIncrement As System.Windows.Forms.Label Protected WithEvents updnIncrement As System.Windows.Forms.NumericUpDown Protected WithEvents lblDecimalPlaces As System.Windows.Forms.Label Protected WithEvents updnDecimalPlaces As System.Windows.Forms.NumericUpDown Protected WithEvents chkSorted As System.Windows.Forms.CheckBox Protected WithEvents lblUpDownAlignment As System.Windows.Forms.Label Protected WithEvents lblTextAlign As System.Windows.Forms.Label Protected WithEvents chkInterceptArrowKeys As System.Windows.Forms.CheckBox Protected WithEvents chkWrap As System.Windows.Forms.CheckBox Protected WithEvents grpCommonProperties As System.Windows.Forms.GroupBox Protected WithEvents numericUpDown1 As System.Windows.Forms.NumericUpDown Protected WithEvents domainUpDown1 As System.Windows.Forms.DomainUpDown Protected WithEvents grpDomainUpDown As System.Windows.Forms.GroupBox Protected WithEvents grpNumericUpDown As System.Windows.Forms.GroupBox
Private WithEvents UpDownCtl As System.Windows.Forms.Form
Private Sub InitializeComponent() Me.grpCommonProperties = New System.Windows.Forms.GroupBox() Me.updnUpDownAlignment = New System.Windows.Forms.DomainUpDown() Me.updnTextAlign = New System.Windows.Forms.DomainUpDown() Me.lblUpDownAlignment = New System.Windows.Forms.Label() Me.lblTextAlign = New System.Windows.Forms.Label() Me.chkInterceptArrowKeys = New System.Windows.Forms.CheckBox() Me.lblDecimalPlaces = New System.Windows.Forms.Label() Me.grpDomainUpDown = New System.Windows.Forms.GroupBox() Me.chkSorted = New System.Windows.Forms.CheckBox() Me.chkWrap = New System.Windows.Forms.CheckBox() Me.domainUpDown1 = New System.Windows.Forms.DomainUpDown() Me.updnDecimalPlaces = New System.Windows.Forms.NumericUpDown() Me.updnIncrement = New System.Windows.Forms.NumericUpDown() Me.lblIncrement = New System.Windows.Forms.Label() Me.numericUpDown1 = New System.Windows.Forms.NumericUpDown() Me.grpNumericUpDown = New System.Windows.Forms.GroupBox() Me.grpCommonProperties.SuspendLayout() Me.grpDomainUpDown.SuspendLayout() CType(Me.updnDecimalPlaces, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.updnIncrement, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.numericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit() Me.grpNumericUpDown.SuspendLayout() Me.SuspendLayout() ' Me.grpCommonProperties.Controls.AddRange(New System.Windows.Forms.Control() {Me.updnUpDownAlignment, Me.updnTextAlign, Me.lblUpDownAlignment, Me.lblTextAlign, Me.chkInterceptArrowKeys}) Me.grpCommonProperties.Location = New System.Drawing.Point(16, 214) Me.grpCommonProperties.Name = "grpCommonProperties" Me.grpCommonProperties.Size = New System.Drawing.Size(472, 107) Me.grpCommonProperties.TabIndex = 2 Me.grpCommonProperties.TabStop = False Me.grpCommonProperties.Text = "CommonProperties" ' 'updnUpDownAlignment ' Me.updnUpDownAlignment.Location = New System.Drawing.Point(152, 61) Me.updnUpDownAlignment.Name = "updnUpDownAlignment" Me.updnUpDownAlignment.TabIndex = 4 ' 'updnTextAlign ' Me.updnTextAlign.Location = New System.Drawing.Point(152, 31) Me.updnTextAlign.Name = "updnTextAlign" Me.updnTextAlign.TabIndex = 3 ' 'lblUpDownAlignment ' Me.lblUpDownAlignment.Location = New System.Drawing.Point(16, 61) Me.lblUpDownAlignment.Name = "lblUpDownAlignment" Me.lblUpDownAlignment.Size = New System.Drawing.Size(120, 23) Me.lblUpDownAlignment.TabIndex = 2 Me.lblUpDownAlignment.Text = "上下对齐" ' 'lblTextAlign ' Me.lblTextAlign.Location = New System.Drawing.Point(16, 31) Me.lblTextAlign.Name = "lblTextAlign" Me.lblTextAlign.Size = New System.Drawing.Size(120, 22) Me.lblTextAlign.TabIndex = 1 Me.lblTextAlign.Text = "文本行" Me.lblTextAlign.TextAlign = System.Drawing.ContentAlignment.BottomLeft ' 'chkInterceptArrowKeys ' Me.chkInterceptArrowKeys.Checked = True Me.chkInterceptArrowKeys.CheckState = System.Windows.Forms.CheckState.Checked Me.chkInterceptArrowKeys.Location = New System.Drawing.Point(304, 31) Me.chkInterceptArrowKeys.Name = "chkInterceptArrowKeys" Me.chkInterceptArrowKeys.Size = New System.Drawing.Size(144, 22) Me.chkInterceptArrowKeys.TabIndex = 0 Me.chkInterceptArrowKeys.Text = "指示上下箭头" ' 'lblDecimalPlaces ' Me.lblDecimalPlaces.Location = New System.Drawing.Point(10, 76) Me.lblDecimalPlaces.Name = "lblDecimalPlaces" Me.lblDecimalPlaces.Size = New System.Drawing.Size(96, 23) Me.lblDecimalPlaces.TabIndex = 3 Me.lblDecimalPlaces.Text = "小数位" ' 'grpDomainUpDown ' Me.grpDomainUpDown.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkSorted, Me.chkWrap, Me.domainUpDown1}) Me.grpDomainUpDown.Location = New System.Drawing.Point(260, 23) Me.grpDomainUpDown.Name = "grpDomainUpDown" Me.grpDomainUpDown.Size = New System.Drawing.Size(230, 168) Me.grpDomainUpDown.TabIndex = 1 Me.grpDomainUpDown.TabStop = False Me.grpDomainUpDown.Text = "DomainUpDown" ' 'chkSorted ' Me.chkSorted.Location = New System.Drawing.Point(10, 115) Me.chkSorted.Name = "chkSorted" Me.chkSorted.Size = New System.Drawing.Size(104, 23) Me.chkSorted.TabIndex = 2 Me.chkSorted.Text = "分类" ' 'chkWrap ' Me.chkWrap.Location = New System.Drawing.Point(10, 76) Me.chkWrap.Name = "chkWrap" Me.chkWrap.Size = New System.Drawing.Size(104, 23) Me.chkWrap.TabIndex = 1 Me.chkWrap.Text = "转换" ' 'domainUpDown1 ' Me.domainUpDown1.Location = New System.Drawing.Point(5, 31) Me.domainUpDown1.Name = "domainUpDown1" Me.domainUpDown1.ReadOnly = True Me.domainUpDown1.Size = New System.Drawing.Size(220, 21) Me.domainUpDown1.TabIndex = 0 ' 'updnDecimalPlaces ' Me.updnDecimalPlaces.Location = New System.Drawing.Point(120, 76) Me.updnDecimalPlaces.Maximum = New Decimal(New Integer() {10, 0, 0, 0}) Me.updnDecimalPlaces.Name = "updnDecimalPlaces" Me.updnDecimalPlaces.Size = New System.Drawing.Size(105, 21) Me.updnDecimalPlaces.TabIndex = 1 Me.updnDecimalPlaces.Value = New Decimal(New Integer() {2, 0, 0, 0}) ' 'updnIncrement ' Me.updnIncrement.DecimalPlaces = 2 Me.updnIncrement.Location = New System.Drawing.Point(120, 115) Me.updnIncrement.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) Me.updnIncrement.Name = "updnIncrement" Me.updnIncrement.Size = New System.Drawing.Size(105, 21) Me.updnIncrement.TabIndex = 2 Me.updnIncrement.Value = New Decimal(New Integer() {1, 0, 0, 0}) ' 'lblIncrement ' Me.lblIncrement.Location = New System.Drawing.Point(10, 115) Me.lblIncrement.Name = "lblIncrement" Me.lblIncrement.Size = New System.Drawing.Size(72, 23) Me.lblIncrement.TabIndex = 4 Me.lblIncrement.Text = "增量" ' 'numericUpDown1 ' Me.numericUpDown1.DecimalPlaces = 2 Me.numericUpDown1.Location = New System.Drawing.Point(10, 31) Me.numericUpDown1.Name = "numericUpDown1" Me.numericUpDown1.Size = New System.Drawing.Size(215, 21) Me.numericUpDown1.TabIndex = 0 ' 'grpNumericUpDown ' Me.grpNumericUpDown.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblIncrement, Me.updnIncrement, Me.lblDecimalPlaces, Me.updnDecimalPlaces, Me.numericUpDown1}) Me.grpNumericUpDown.Location = New System.Drawing.Point(16, 23) Me.grpNumericUpDown.Name = "grpNumericUpDown" Me.grpNumericUpDown.Size = New System.Drawing.Size(232, 168) Me.grpNumericUpDown.TabIndex = 0 Me.grpNumericUpDown.TabStop = False Me.grpNumericUpDown.Text = "NumericUpDown" ' 'UpDownCtl ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(504, 336) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.grpCommonProperties, Me.grpDomainUpDown, Me.grpNumericUpDown}) Me.Name = "UpDownCtl" Me.Text = "UpDownCtlForm" Me.grpCommonProperties.ResumeLayout(False) Me.grpDomainUpDown.ResumeLayout(False) CType(Me.updnDecimalPlaces, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.updnIncrement, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.numericUpDown1, System.ComponentModel.ISupportInitialize).EndInit() Me.grpNumericUpDown.ResumeLayout(False) Me.ResumeLayout(False)
End Sub
#End Region
' The main entry point for the application. <STAThread()> Public Shared Sub Main() Application.Run(New UpDownCtl()) End Sub
Private Sub grpCommonProperties_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpCommonProperties.Enter
End Sub
Private Sub lblTextAlign_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTextAlign.Click
End Sub End Class
End Namespace