📄 texteditor.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
Public Property StatusText() As String
Get
Return StatusBar.Text
End Get
Set(ByVal Value As String)
StatusBar.Text = Value
End Set
End Property
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
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 ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents tbrClear As System.Windows.Forms.ToolBarButton
Friend WithEvents tbrRed As System.Windows.Forms.ToolBarButton
Friend WithEvents tbrUpperCase As System.Windows.Forms.ToolBarButton
Friend WithEvents tbrLowercase As System.Windows.Forms.ToolBarButton
Friend WithEvents tbrAbout As System.Windows.Forms.ToolBarButton
Friend WithEvents imglstToolbar As System.Windows.Forms.ImageList
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton4 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton5 As System.Windows.Forms.ToolBarButton
Friend WithEvents StatusBar As System.Windows.Forms.StatusBar
Friend WithEvents txtEdit As System.Windows.Forms.TextBox
Friend WithEvents ToolBarButton6 As System.Windows.Forms.ToolBarButton
Friend WithEvents tbrBlue As System.Windows.Forms.ToolBarButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton6 = New System.Windows.Forms.ToolBarButton
Me.tbrClear = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.tbrRed = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
Me.tbrBlue = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton
Me.tbrUpperCase = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton
Me.tbrLowercase = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton
Me.tbrAbout = New System.Windows.Forms.ToolBarButton
Me.imglstToolbar = New System.Windows.Forms.ImageList(Me.components)
Me.StatusBar = New System.Windows.Forms.StatusBar
Me.txtEdit = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton6, Me.tbrClear, Me.ToolBarButton1, Me.tbrRed, Me.ToolBarButton2, Me.tbrBlue, Me.ToolBarButton3, Me.tbrUpperCase, Me.ToolBarButton4, Me.tbrLowercase, Me.ToolBarButton5, Me.tbrAbout})
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.imglstToolbar
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(592, 41)
Me.ToolBar1.TabIndex = 0
'
'ToolBarButton6
'
Me.ToolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrClear
'
Me.tbrClear.ImageIndex = 1
Me.tbrClear.Text = "New"
'
'ToolBarButton1
'
Me.ToolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrRed
'
Me.tbrRed.ImageIndex = 2
Me.tbrRed.Text = "Red"
'
'ToolBarButton2
'
Me.ToolBarButton2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrBlue
'
Me.tbrBlue.ImageIndex = 3
Me.tbrBlue.Text = "Blue"
'
'ToolBarButton3
'
Me.ToolBarButton3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrUpperCase
'
Me.tbrUpperCase.ImageIndex = 4
Me.tbrUpperCase.Text = "Uppercase"
'
'ToolBarButton4
'
Me.ToolBarButton4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrLowercase
'
Me.tbrLowercase.ImageIndex = 5
Me.tbrLowercase.Text = "Lowercase"
'
'ToolBarButton5
'
Me.ToolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
'
'tbrAbout
'
Me.tbrAbout.ImageIndex = 0
Me.tbrAbout.Text = "About"
'
'imglstToolbar
'
Me.imglstToolbar.ImageSize = New System.Drawing.Size(16, 16)
Me.imglstToolbar.ImageStream = CType(resources.GetObject("imglstToolbar.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.imglstToolbar.TransparentColor = System.Drawing.Color.Transparent
'
'StatusBar
'
Me.StatusBar.Location = New System.Drawing.Point(0, 404)
Me.StatusBar.Name = "StatusBar"
Me.StatusBar.Size = New System.Drawing.Size(592, 22)
Me.StatusBar.TabIndex = 1
Me.StatusBar.Text = "StatusBar1"
'
'txtEdit
'
Me.txtEdit.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtEdit.Location = New System.Drawing.Point(0, 41)
Me.txtEdit.Multiline = True
Me.txtEdit.Name = "txtEdit"
Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtEdit.Size = New System.Drawing.Size(592, 363)
Me.txtEdit.TabIndex = 2
Me.txtEdit.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(592, 426)
Me.Controls.Add(Me.txtEdit)
Me.Controls.Add(Me.StatusBar)
Me.Controls.Add(Me.ToolBar1)
Me.Name = "Form1"
Me.Text = "TextEditor"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
If e.Button Is tbrClear Then
ClearEditBox()
Exit Sub
End If
If e.Button Is tbrRed Then
RedText()
Exit Sub
End If
If e.Button Is tbrBlue Then
BlueText()
Exit Sub
End If
If e.Button Is tbrUpperCase Then
UppercaseText()
Exit Sub
End If
If e.Button Is tbrLowercase Then
LowercaseText()
Exit Sub
End If
If e.Button Is tbrAbout Then
ShowAboutBox()
End If
End Sub
Private Sub StatusBar1_PanelClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.StatusBarPanelClickEventArgs) Handles StatusBar.PanelClick
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Property EditText() As String
Get
Return txtEdit.Text
End Get
Set(ByVal Value As String)
txtEdit.Text = Value
End Set
End Property
Public Sub ClearEditBox()
EditText = String.Empty
txtEdit.ForeColor = Color.Black
StatusText = "Text box cleared"
End Sub
Public Sub RedText()
txtEdit.ForeColor = Color.Red
StatusText = "The text is red"
End Sub
Public Sub BlueText()
txtEdit.ForeColor = Color.Blue
StatusText = "The text is blue"
End Sub
Public Sub UppercaseText()
EditText = EditText.ToUpper
StatusText = "The text is all uppercase"
End Sub
Public Sub LowercaseText()
EditText = EditText.ToLower
StatusText = "The text is all lowercase"
End Sub
Public Sub ShowAboutBox()
Dim aboutBox As New About
aboutBox.ShowDialog(Me)
End Sub
Private Sub txtEdit_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEdit.TextChanged
StatusText = "Ready"
End Sub
Private Sub tbrClear_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbrClear.Disposed
End Sub
Private Sub tbrRed_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbrRed.Disposed
End Sub
Private Sub ToolBar1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolBar1.Click
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -