Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
  • Leaders
Posted

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.

MyRTF.SelectionFont = new Font(MyRTF.SelectionFont, MyRTF.SelectionFont.Style ^ FontStyle.Bold);

[sIGPIC]e[/sIGPIC]
Posted

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.

 

  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

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...