047状态栏Status

   为子窗体创建一个简单的状态栏。该状态栏包含四个面板,其中三个将显示图像和文本,另外一个只显示文本。
    (l)在“工具箱”中双击StatusStrip控件,将它添加到对话框中。
    (2)在“属性”窗口中单击Items属性中的省略号(…),打开“项集合编辑器”窗体。
    (3)添加四个StatusStripStatusLabel面板。

047状态栏Status_第1张图片

  (4)修改粗体、斜体,下划线菜单项的事件处理程序。
 

 '粗体
    Private Sub BoldMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BoldMenuItem.Click
        '当前字体
        Dim pCurrentFont As Font
        pCurrentFont = txtContent.SelectionFont

        Dim pFontStyle As FontStyle
        If Not pCurrentFont.Bold Then
            pFontStyle += FontStyle.Bold
            tsslBold.Enabled = True
        Else
            tsslBold.Enabled = True
        End If
        If pCurrentFont.Italic Then
            pFontStyle += FontStyle.Italic
        End If
        If pCurrentFont.Underline Then
            pFontStyle += FontStyle.Underline
        End If

        txtContent.Font = New Font(pCurrentFont, pFontStyle)
        txtContent.Focus()
    End Sub
    '下划线
    Private Sub UnderlinMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnderlinMenuItem.Click
        '当前字体
        Dim pCurrentFont As Font
        pCurrentFont = txtContent.SelectionFont

        Dim pFontStyle As FontStyle
        If pCurrentFont.Bold Then
            pFontStyle += FontStyle.Bold
        End If
        If pCurrentFont.Italic Then
            pFontStyle += FontStyle.Italic
        End If
        If Not pCurrentFont.Underline Then
            pFontStyle += FontStyle.Underline
            tsslUnderline.Enabled = True
        Else
            tsslUnderline.Enabled = False
        End If

        txtContent.Font = New Font(pCurrentFont, pFontStyle)
        txtContent.Focus()
    End Sub
    '斜体
    Private Sub ItalicMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItalicMenuItem.Click
        '当前字体
        Dim pCurrentFont As Font
        pCurrentFont = txtContent.SelectionFont

        Dim pFontStyle As FontStyle
        If pCurrentFont.Bold Then
            pFontStyle += FontStyle.Bold
        End If
        If Not pCurrentFont.Italic Then
            pFontStyle += FontStyle.Italic
            tsslItalic.Enabled = False
        Else
            tsslItalic.Enabled = True
        End If
        If pCurrentFont.Underline Then
            pFontStyle += FontStyle.Underline
        End If

        txtContent.Font = New Font(pCurrentFont, pFontStyle)
        txtContent.Focus()
    End Sub

(5)  修改RichTextBox控件的TextChanged事件处理程序。

Private Sub txtContent_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtContent.TextChanged
        bSave = False
        tsslText.Text = "字符数:" & txtContent.Text.Length
End Sub

 

你可能感兴趣的:(#,Visual,Basic,2010,基础)