Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
am trying to use a chack button to set font FontStyle but it not working i will like my to use more then one FontStyle in a richtextbox here is my code

VB
Private Sub ToggleStyle(ByVal style As FontStyle)
        Try
            mbody.SelectionFont = New Font(mbody.SelectionFont, mbody.SelectionFont.Style Xor style)

        Catch ex As Exception

        End Try
    End Sub


VB
Private Sub Boldmain_Click(sender As Object, e As EventArgs) Handles Boldmain.Click
      ToggleStyle(Drawing.FontStyle.Bold)
  End Sub

but it not working only gives Object reference not set to an instance of an object.
Posted
Updated 24-Dec-14 5:34am
v2
Comments
CHill60 24-Dec-14 11:27am    
Try putting MessageBox.Show(ex.Message) in your catch clause to find out what is going wrong
OriginalGriff 24-Dec-14 11:28am    
"it not working" tells us very little.
What is it doing that you didn't expect, or not doing that you did?


Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Sergey Alexandrovich Kryukov 24-Dec-14 11:29am    
What is mbody? Did you select anything before clicking. Click on what (could it possibly deselect, for example?)?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900