📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 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
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents grpMonths As System.Windows.Forms.GroupBox
Friend WithEvents dtpMonths As System.Windows.Forms.DateTimePicker
Friend WithEvents mcMonths As System.Windows.Forms.MonthCalendar
Friend WithEvents rbJan As System.Windows.Forms.RadioButton
Friend WithEvents rbFeb As System.Windows.Forms.RadioButton
Friend WithEvents rbMar As System.Windows.Forms.RadioButton
Friend WithEvents rbApr As System.Windows.Forms.RadioButton
Friend WithEvents rbMay As System.Windows.Forms.RadioButton
Friend WithEvents rbJun As System.Windows.Forms.RadioButton
Friend WithEvents rbJul As System.Windows.Forms.RadioButton
Friend WithEvents rbAug As System.Windows.Forms.RadioButton
Friend WithEvents rbSep As System.Windows.Forms.RadioButton
Friend WithEvents rbOct As System.Windows.Forms.RadioButton
Friend WithEvents rbNov As System.Windows.Forms.RadioButton
Friend WithEvents rbDec As System.Windows.Forms.RadioButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.grpMonths = New System.Windows.Forms.GroupBox()
Me.rbJan = New System.Windows.Forms.RadioButton()
Me.rbFeb = New System.Windows.Forms.RadioButton()
Me.rbMar = New System.Windows.Forms.RadioButton()
Me.rbApr = New System.Windows.Forms.RadioButton()
Me.rbMay = New System.Windows.Forms.RadioButton()
Me.rbJun = New System.Windows.Forms.RadioButton()
Me.rbJul = New System.Windows.Forms.RadioButton()
Me.rbAug = New System.Windows.Forms.RadioButton()
Me.rbSep = New System.Windows.Forms.RadioButton()
Me.rbOct = New System.Windows.Forms.RadioButton()
Me.rbNov = New System.Windows.Forms.RadioButton()
Me.rbDec = New System.Windows.Forms.RadioButton()
Me.dtpMonths = New System.Windows.Forms.DateTimePicker()
Me.mcMonths = New System.Windows.Forms.MonthCalendar()
Me.grpMonths.SuspendLayout()
Me.SuspendLayout()
'
'grpMonths
'
Me.grpMonths.Controls.AddRange(New System.Windows.Forms.Control() {Me.rbJan, Me.rbFeb, Me.rbMar, Me.rbApr, Me.rbMay, Me.rbJun, Me.rbJul, Me.rbAug, Me.rbSep, Me.rbOct, Me.rbNov, Me.rbDec})
Me.grpMonths.Location = New System.Drawing.Point(8, 8)
Me.grpMonths.Name = "grpMonths"
Me.grpMonths.Size = New System.Drawing.Size(168, 224)
Me.grpMonths.TabIndex = 0
Me.grpMonths.TabStop = False
Me.grpMonths.Text = "月份"
'
'rbJan
'
Me.rbJan.Location = New System.Drawing.Point(16, 24)
Me.rbJan.Name = "rbJan"
Me.rbJan.Size = New System.Drawing.Size(56, 24)
Me.rbJan.TabIndex = 0
Me.rbJan.Text = "一月"
'
'rbFeb
'
Me.rbFeb.Location = New System.Drawing.Point(16, 56)
Me.rbFeb.Name = "rbFeb"
Me.rbFeb.Size = New System.Drawing.Size(56, 24)
Me.rbFeb.TabIndex = 0
Me.rbFeb.Text = "二月"
'
'rbMar
'
Me.rbMar.Location = New System.Drawing.Point(16, 88)
Me.rbMar.Name = "rbMar"
Me.rbMar.Size = New System.Drawing.Size(56, 24)
Me.rbMar.TabIndex = 0
Me.rbMar.Text = "三月"
'
'rbApr
'
Me.rbApr.Location = New System.Drawing.Point(16, 120)
Me.rbApr.Name = "rbApr"
Me.rbApr.Size = New System.Drawing.Size(56, 24)
Me.rbApr.TabIndex = 0
Me.rbApr.Text = "四月"
'
'rbMay
'
Me.rbMay.Location = New System.Drawing.Point(16, 152)
Me.rbMay.Name = "rbMay"
Me.rbMay.Size = New System.Drawing.Size(56, 24)
Me.rbMay.TabIndex = 0
Me.rbMay.Text = "五月"
'
'rbJun
'
Me.rbJun.Location = New System.Drawing.Point(16, 184)
Me.rbJun.Name = "rbJun"
Me.rbJun.Size = New System.Drawing.Size(56, 24)
Me.rbJun.TabIndex = 0
Me.rbJun.Text = "六月"
'
'rbJul
'
Me.rbJul.Location = New System.Drawing.Point(96, 24)
Me.rbJul.Name = "rbJul"
Me.rbJul.Size = New System.Drawing.Size(56, 24)
Me.rbJul.TabIndex = 0
Me.rbJul.Text = "七月"
'
'rbAug
'
Me.rbAug.Location = New System.Drawing.Point(96, 56)
Me.rbAug.Name = "rbAug"
Me.rbAug.Size = New System.Drawing.Size(56, 24)
Me.rbAug.TabIndex = 0
Me.rbAug.Text = "八月"
'
'rbSep
'
Me.rbSep.Location = New System.Drawing.Point(96, 88)
Me.rbSep.Name = "rbSep"
Me.rbSep.Size = New System.Drawing.Size(56, 24)
Me.rbSep.TabIndex = 0
Me.rbSep.Text = "九月"
'
'rbOct
'
Me.rbOct.Location = New System.Drawing.Point(96, 120)
Me.rbOct.Name = "rbOct"
Me.rbOct.Size = New System.Drawing.Size(56, 24)
Me.rbOct.TabIndex = 0
Me.rbOct.Text = "十月"
'
'rbNov
'
Me.rbNov.Location = New System.Drawing.Point(96, 152)
Me.rbNov.Name = "rbNov"
Me.rbNov.Size = New System.Drawing.Size(64, 24)
Me.rbNov.TabIndex = 0
Me.rbNov.Text = "十一月"
'
'rbDec
'
Me.rbDec.Location = New System.Drawing.Point(96, 184)
Me.rbDec.Name = "rbDec"
Me.rbDec.Size = New System.Drawing.Size(64, 24)
Me.rbDec.TabIndex = 0
Me.rbDec.Text = "十二月"
'
'dtpMonths
'
Me.dtpMonths.Location = New System.Drawing.Point(192, 176)
Me.dtpMonths.Name = "dtpMonths"
Me.dtpMonths.Size = New System.Drawing.Size(136, 21)
Me.dtpMonths.TabIndex = 1
'
'mcMonths
'
Me.mcMonths.Location = New System.Drawing.Point(192, 8)
Me.mcMonths.Name = "mcMonths"
Me.mcMonths.TabIndex = 2
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(480, 246)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.mcMonths, Me.dtpMonths, Me.grpMonths})
Me.Name = "Form1"
Me.Text = "Form1"
Me.grpMonths.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ChangeMonth(ByVal month As Integer)
If month >= 1 And month <= 12 Then
Dim newDate As New DateTime(dtpMonths.Value.Year, month, 1)
dtpMonths.Value = newDate
mcMonths.SelectionStart = newDate
mcMonths.SelectionEnd = newDate.AddDays(3)
End If
End Sub
Private Sub rbJan_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbJan.CheckedChanged
ChangeMonth(1)
End Sub
Private Sub rbFeb_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbFeb.CheckedChanged
ChangeMonth(2)
End Sub
Private Sub rbMar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbMar.CheckedChanged
ChangeMonth(3)
End Sub
Private Sub rbApr_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbApr.CheckedChanged
ChangeMonth(4)
End Sub
Private Sub rbMay_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbMay.CheckedChanged
ChangeMonth(5)
End Sub
Private Sub rbJun_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbJun.CheckedChanged
ChangeMonth(6)
End Sub
Private Sub rbJul_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbJul.CheckedChanged
ChangeMonth(7)
End Sub
Private Sub rbAug_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbAug.CheckedChanged
ChangeMonth(8)
End Sub
Private Sub rbSep_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbSep.CheckedChanged
ChangeMonth(9)
End Sub
Private Sub rbOct_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbOct.CheckedChanged
ChangeMonth(10)
End Sub
Private Sub rbNov_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbNov.CheckedChanged
ChangeMonth(11)
End Sub
Private Sub rbDec_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbDec.CheckedChanged
ChangeMonth(12)
End Sub
Private Sub dtpMonths_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtpMonths.ValueChanged
mcMonths.TodayDate = dtpMonths.Value
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -