G
Guest
I’m writing a Windows application with VB.NET. The application I’m creating
using a user control which I have written. The user control has some buttons,
Panels, Combobox and a Rich textbox. The user control would like to edit some
text in the textbox but getting problem. (My Rich textbox is called rtManus).
My problem code is:
If Not rtManus.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font = rtManus.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If rtManus.SelectionFont.Bold = False Then
newFontStyle = FontStyle.Bold
End If
rtManus.SelectionFont = New Font(currentFont.FontFamily, _
currentFont.Size, newFontStyle)
End If
Error message is: Object reference not set to an instance of an object.
The code is working well two times, but the third time it crash. This code
has been copied from .NET help. Can anyone tell me what the problem is, pleas?
using a user control which I have written. The user control has some buttons,
Panels, Combobox and a Rich textbox. The user control would like to edit some
text in the textbox but getting problem. (My Rich textbox is called rtManus).
My problem code is:
If Not rtManus.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font = rtManus.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If rtManus.SelectionFont.Bold = False Then
newFontStyle = FontStyle.Bold
End If
rtManus.SelectionFont = New Font(currentFont.FontFamily, _
currentFont.Size, newFontStyle)
End If
Error message is: Object reference not set to an instance of an object.
The code is working well two times, but the third time it crash. This code
has been copied from .NET help. Can anyone tell me what the problem is, pleas?