Post by bobowk on Jun 30, 2016 11:57:41 GMT 10
If I press all four buttons (bold, italic, underlined and strikeout), Their backcolor should be set as gainsboro... But it doesn't. I think I have discovered the problem which is located in the updateproperties() sub. Here is the code if you don't know it already...
Public Sub UpdateProperties()
Try
CurrentFont = RichTextBox1.SelectionFont.FontFamily
CurrentForeColor = RichTextBox1.SelectionColor
CurrentSize = RichTextBox1.SelectionFont.Size
ColorDialog1.Color = CurrentForeColor
Panel2.BackColor = RichTextBox1.SelectionColor
If RichTextBox1.SelectionFont.Style = FontStyle.Bold Then
ButtonBold.BackColor = Color.Gainsboro
Else
ButtonBold.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionFont.Style = FontStyle.Italic Then
ButtonItalic.BackColor = Color.Gainsboro
Else
ButtonItalic.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionFont.Style = FontStyle.Underline Then
ButtonUnderlined.BackColor = Color.Gainsboro
Else
ButtonUnderlined.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionFont.Style = FontStyle.Strikeout Then
ButtonStrikeout.BackColor = Color.Gainsboro
Else
ButtonStrikeout.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionAlignment = HorizontalAlignment.Left Then
ButtonLeft.BackColor = Color.Gainsboro
Else
ButtonLeft.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionAlignment = HorizontalAlignment.Center Then
ButtonCenter.BackColor = Color.Gainsboro
Else
ButtonCenter.BackColor = Color.WhiteSmoke
End If
If RichTextBox1.SelectionAlignment = HorizontalAlignment.Right Then
ButtonRight.BackColor = Color.Gainsboro
Else
ButtonRight.BackColor = Color.WhiteSmoke
End If
Catch ex As Exception
End Try
End Sub
It is the same problem as setting all 4 fontstyles for the selectiontext... If it is
If RichTextBox1.SelectionFont = FontStyle.Bold Then It won't work.... Because if I do FontStyle.Italic then the bold won't stay and there because it gets deleted when it changes from fontstyle.bold to fontstyle.italic. Is there a work around? Thanks, Brandon
|
|