📄 form3.vb
字号:
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3, Me.ToolBarButton4})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(504, 41)
Me.ToolBar1.TabIndex = 4
'
'ToolBarButton1
'
Me.ToolBarButton1.Text = "复制"
'
'ToolBarButton2
'
Me.ToolBarButton2.Text = "粘贴"
'
'ToolBarButton3
'
Me.ToolBarButton3.Text = "剪切"
'
'ToolBarButton4
'
Me.ToolBarButton4.Text = "撤消"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(432, 248)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(36, 12)
Me.Button3.TabIndex = 5
Me.Button3.Text = "Button3"
Me.Button3.Visible = False
'
'Timer1
'
'
'ColorDialog1
'
Me.ColorDialog1.FullOpen = True
'
'FontDialog1
'
'
'RichTextBox1
'
Me.RichTextBox1.Location = New System.Drawing.Point(32, 56)
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Size = New System.Drawing.Size(400, 176)
Me.RichTextBox1.TabIndex = 6
Me.RichTextBox1.Text = ""
'
'SaveFileDialog1
'
Me.SaveFileDialog1.CreatePrompt = True
'
'Form3
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(504, 286)
Me.Controls.Add(Me.RichTextBox1)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.ToolBar1)
Me.Controls.Add(Me.StatusBar1)
Me.Menu = Me.MainMenu1
Me.Name = "Form3"
Me.Text = "Form3"
CType(Me.statusbar_date, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusbar_time, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusbar_txtlength, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub StatusBar1_PanelClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.StatusBarPanelClickEventArgs) Handles StatusBar1.PanelClick
End Sub
Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem9.Click
Dim objtext As RichTextBox = Me.ActiveControl
objtext.Copy()
End Sub
Private Sub MenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem10.Click
Dim objtext As RichTextBox = Me.ActiveControl
objtext.Cut()
End Sub
Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem11.Click
Dim objtext As RichTextBox = Me.ActiveControl
objtext.Paste()
End Sub
Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim objtext As RichTextBox = Me.ActiveControl
objtext.Undo()
End Sub
Private Sub MenuItem13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem13.Click
Dim objtext As RichTextBox = Me.ActiveControl
objtext.SelectAll()
End Sub
Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim objtext As RichTextBox = Me.ActiveControl
objtext.Undo()
End Sub
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
statusbar_txtlength.Text = "文本框中的字符数为:" & RichTextBox1.TextLength
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
MenuItem9_Click(Nothing, Nothing)
Case 1
MenuItem11_Click(Nothing, Nothing)
Case 2
MenuItem10_Click(Nothing, Nothing)
Case 3
MenuItem14_Click(Nothing, Nothing)
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim cmnuFirst As ContextMenu
cmnuFirst = New ContextMenu
cmnuFirst.MenuItems.Add("撤消")
cmnuFirst.MenuItems.Add("-")
cmnuFirst.MenuItems.Add("复制")
cmnuFirst.MenuItems.Add("剪切")
cmnuFirst.MenuItems.Add("粘贴")
cmnuFirst.MenuItems.Add("删除")
RichTextBox1.ContextMenu = cmnuFirst
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
statusbar_date.Text = "系统当前的日期为:" & Format(Now, "yyyy-MM-dd")
statusbar_time.Text = "系统当前的时间为:" & Format(Now, "hh:mm:ss")
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem17.Click
FontDialog1.ShowApply = True
FontDialog1.ShowColor = True
FontDialog1.ShowHelp = True
If FontDialog1.ShowDialog = DialogResult.OK Then
RichTextBox1.Font = FontDialog1.Font
RichTextBox1.ForeColor = FontDialog1.Color
End If
End Sub
Private Sub MenuItem18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem18.Click
If ColorDialog1.ShowDialog() = DialogResult.OK Then
RichTextBox1.BackColor = ColorDialog1.Color
End If
End Sub
Private Sub FontDialog1_Apply(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontDialog1.Apply
RichTextBox1.Font = FontDialog1.Font
RichTextBox1.ForeColor = FontDialog1.Color
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
RichTextBox1.Clear()
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
OpenFileDialog1.ShowDialog()
Dim openfilename As String
openfilename = OpenFileDialog1.FileName
Dim openfile As New System.IO.StreamReader(openfilename)
RichTextBox1.Text = openfile.ReadToEnd
openfile.Close()
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
SaveFileDialog1.ShowDialog()
Dim savefile As New System.IO.StreamWriter(SaveFileDialog1.FileName)
savefile.Write(RichTextBox1.Text)
savefile.Close()
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
End
End Sub
Private Sub RichTextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
statusbar_txtlength.Text = "文本框中的字符数为:" & RichTextBox1.TextLength
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -