047状态栏Status

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

  (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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ngbshzhn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值