Unbolding

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
I have a button that bolds selected text in an Rtf textbox. The problem is I want to be able to unbold the selected text if they click the bold button again the and the selected text is bolded. Just adding and undo button will not work because the user could have made several changes since bolding the selected text. Basically I want it to work like Word. This has to be in Visual Basic.NET. Any help given is greatly appreciated.
 
What is the problem? Why not check if the font is bold, and if so make it not bold, if not make it bold.

Or, here is a niftier solution. This code toggles whether or not text is bold in one step.
C#:
MyRTF.SelectionFont = new Font(MyRTF.SelectionFont, MyRTF.SelectionFont.Style ^ FontStyle.Bold);
 
Maybe this can help. Here is what I do for a pause button that when pressed again, my test continues. Somewhat the same concept of what you are asking.

Visual Basic:
   Private Sub btnPauseTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPauseTest.Click
        If Me.btnPauseTest.Text = "PAUSE" Then
            If thrdTest.IsAlive Then thrdTest.Suspend()
            Me.tmrTestTime.Enabled = False
            Me.btnPauseTest.Text = "CONTINUE"
        Else
            If thrdTest.IsAlive Then thrdTest.Resume()
            Me.tmrTestTime.Enabled = True
            Me.btnPauseTest.Text = "PAUSE"
        End If
    End Sub
 
Back
Top