|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
richtextbox changing fontstyles for selected textA selected text has fontstyles like bold and italic and underscore
I want to remove one of them without changing the other fontstyles. How to do that? Thanks for any response Hmm... I don't think that is too difficult. The rich text box has
properties - Selbold, selitalic and so on.. Just use that. Regards Cyril Gupta I am using RTB from vb.net and these propperties don't exist anymore.
I don't think there is a short replacement for them. I now have found in internet a userclass to replace these properties. Cyril, thanks any way Show quoteHide quote "Cyril Gupta" <nomail@nospam.com> wrote in message news:eFg9mvcjGHA.456@TK2MSFTNGP05.phx.gbl... > Hmm... I don't think that is too difficult. The rich text box has > properties - Selbold, selitalic and so on.. Just use that. > > Regards > Cyril Gupta > > "andreas" <andr***@pandora.be> schrieb: Unfortunately there is no clean way to archieve that using the .NET >A selected text has fontstyles like bold and italic and underscore > I want to remove one of them without changing the other fontstyles. > How to do that? richtextbox control because of the rather awkward wrapper around the character styles. However, you can use p/invoke with 'SendMessage' + 'EM_SETPARAFORMAT' (see MSDN) instead. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks Herfried, but I am a little newbie.
I want to use this class if it is possible I use a richtextbox frOm vb.net and when I select words I can click a menubutton Can I use the class in the event button_click? -------------------------------------------------------- Public Class RTBStyles Inherits RichTextBox Public Property SelBold() As Boolean Get Return SelectionFont.Bold End Get Set(ByVal value As Boolean) SelStyle(FontStyle.Bold, value) End Set End Property Public Property SelUnderline() As Boolean Get Return SelectionFont.Underline End Get Set(ByVal value As Boolean) SelStyle(FontStyle.Underline, value) End Set End Property Public Property SelStrikeout() As Boolean Get Return SelectionFont.Strikeout End Get Set(ByVal value As Boolean) SelStyle(FontStyle.Strikeout, value) End Set End Property Public Property SelItalic() As Boolean Get Return SelectionFont.Italic End Get Set(ByVal value As Boolean) SelStyle(FontStyle.Italic, value) End Set End Property Public Property SelRegular() As Boolean Get If ((SelectionFont.Bold = True) Or (SelectionFont.Italic = True) Or (SelectionFont.Underline = True) Or (SelectionFont.Strikeout = True)) Then Return False Else Return True End If End Get Set(ByVal value As Boolean) Dim start As Integer = SelectionStart Dim length As Integer = SelectionLength For i As Integer = 0 To length - 1 SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, FontStyle.Regular) Next Me.Select(start, length) End Set End Property Private Sub SelStyle(ByVal _style As FontStyle, ByVal value As Boolean) Dim start As Integer = SelectionStart Dim length As Integer = SelectionLength For i As Integer = 0 To length - 1 Me.Select(start + i, 1) Dim style As FontStyle If value = True Then style = _style Else style = FontStyle.Regular End If If (SelectionFont.Italic And (FontStyle.Italic <> _style)) Then style = (style Or FontStyle.Italic) If (SelectionFont.Strikeout And (FontStyle.Strikeout <> _style)) Then style = (style Or FontStyle.Strikeout) If (SelectionFont.Bold And (FontStyle.Bold <> _style)) Then style = (style Or FontStyle.Bold) If (SelectionFont.Underline And (FontStyle.Underline <> _style)) Then style = (style Or FontStyle.Underline) SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, style) Next Me.Select(start, length) End Sub End Class ------------------------------------------------------------------ Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:euKBxOgjGHA.4660@TK2MSFTNGP03.phx.gbl... > "andreas" <andr***@pandora.be> schrieb: > >A selected text has fontstyles like bold and italic and underscore > > I want to remove one of them without changing the other fontstyles. > > How to do that? > > > Unfortunately there is no clean way to archieve that using the .NET > richtextbox control because of the rather awkward wrapper around the > character styles. However, you can use p/invoke with 'SendMessage' + > 'EM_SETPARAFORMAT' (see MSDN) instead. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > I beleive I have read somewhere in this group that if the user have
word 2003 installed, he/she can embed word inside a form. Wouldn't that be easier and better than using RTB? Please correct me if I am wrong. andreas wrote: Show quoteHide quote > Thanks Herfried, but I am a little newbie. > I want to use this class if it is possible > I use a richtextbox frOm vb.net and when I select words I can click a > menubutton > Can I use the class in the event button_click? > > -------------------------------------------------------- > Public Class RTBStyles > > Inherits RichTextBox > > Public Property SelBold() As Boolean > > Get > > Return SelectionFont.Bold > > End Get > > Set(ByVal value As Boolean) > > SelStyle(FontStyle.Bold, value) > > End Set > > End Property > > Public Property SelUnderline() As Boolean > > Get > > Return SelectionFont.Underline > > End Get > > Set(ByVal value As Boolean) > > SelStyle(FontStyle.Underline, value) > > End Set > > End Property > > Public Property SelStrikeout() As Boolean > > Get > > Return SelectionFont.Strikeout > > End Get > > Set(ByVal value As Boolean) > > SelStyle(FontStyle.Strikeout, value) > > End Set > > End Property > > Public Property SelItalic() As Boolean > > Get > > Return SelectionFont.Italic > > End Get > > Set(ByVal value As Boolean) > > SelStyle(FontStyle.Italic, value) > > End Set > > End Property > > Public Property SelRegular() As Boolean > > Get > > If ((SelectionFont.Bold = True) Or (SelectionFont.Italic = True) Or > (SelectionFont.Underline = True) Or (SelectionFont.Strikeout = True)) Then > > Return False > > Else > > Return True > > End If > > End Get > > Set(ByVal value As Boolean) > > Dim start As Integer = SelectionStart > > Dim length As Integer = SelectionLength > > For i As Integer = 0 To length - 1 > > SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, > FontStyle.Regular) > > Next > > Me.Select(start, length) > > End Set > > End Property > > > > Private Sub SelStyle(ByVal _style As FontStyle, ByVal value As Boolean) > > Dim start As Integer = SelectionStart > > Dim length As Integer = SelectionLength > > For i As Integer = 0 To length - 1 > > Me.Select(start + i, 1) > > Dim style As FontStyle > > If value = True Then > > style = _style > > Else > > style = FontStyle.Regular > > End If > > If (SelectionFont.Italic And (FontStyle.Italic <> _style)) Then style = > (style Or FontStyle.Italic) > > If (SelectionFont.Strikeout And (FontStyle.Strikeout <> _style)) Then style > = (style Or FontStyle.Strikeout) > > If (SelectionFont.Bold And (FontStyle.Bold <> _style)) Then style = (style > Or FontStyle.Bold) > > If (SelectionFont.Underline And (FontStyle.Underline <> _style)) Then style > = (style Or FontStyle.Underline) > > SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, > style) > > Next > > Me.Select(start, length) > > End Sub > > End Class > > ------------------------------------------------------------------ > > > > > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > news:euKBxOgjGHA.4660@TK2MSFTNGP03.phx.gbl... > > "andreas" <andr***@pandora.be> schrieb: > > >A selected text has fontstyles like bold and italic and underscore > > > I want to remove one of them without changing the other fontstyles. > > > How to do that? > > > > > > Unfortunately there is no clean way to archieve that using the .NET > > richtextbox control because of the rather awkward wrapper around the > > character styles. However, you can use p/invoke with 'SendMessage' + > > 'EM_SETPARAFORMAT' (see MSDN) instead. > > > > -- > > M S Herfried K. Wagner > > M V P <URL:http://dotnet.mvps.org/> > > V B <URL:http://classicvb.org/petition/> > > No, I can't because it is a task in some lessons
Thanks anyway Show quoteHide quote "Ahmed" <ahmed1***@gmail.com> wrote in message news:1150126669.913123.195300@g10g2000cwb.googlegroups.com... > I beleive I have read somewhere in this group that if the user have > word 2003 installed, he/she can embed word inside a form. Wouldn't that > be easier and better than using RTB? > > Please correct me if I am wrong. > > > andreas wrote: > > Thanks Herfried, but I am a little newbie. > > I want to use this class if it is possible > > I use a richtextbox frOm vb.net and when I select words I can click a > > menubutton > > Can I use the class in the event button_click? > > > > -------------------------------------------------------- > > Public Class RTBStyles > > > > Inherits RichTextBox > > > > Public Property SelBold() As Boolean > > > > Get > > > > Return SelectionFont.Bold > > > > End Get > > > > Set(ByVal value As Boolean) > > > > SelStyle(FontStyle.Bold, value) > > > > End Set > > > > End Property > > > > Public Property SelUnderline() As Boolean > > > > Get > > > > Return SelectionFont.Underline > > > > End Get > > > > Set(ByVal value As Boolean) > > > > SelStyle(FontStyle.Underline, value) > > > > End Set > > > > End Property > > > > Public Property SelStrikeout() As Boolean > > > > Get > > > > Return SelectionFont.Strikeout > > > > End Get > > > > Set(ByVal value As Boolean) > > > > SelStyle(FontStyle.Strikeout, value) > > > > End Set > > > > End Property > > > > Public Property SelItalic() As Boolean > > > > Get > > > > Return SelectionFont.Italic > > > > End Get > > > > Set(ByVal value As Boolean) > > > > SelStyle(FontStyle.Italic, value) > > > > End Set > > > > End Property > > > > Public Property SelRegular() As Boolean > > > > Get > > > > If ((SelectionFont.Bold = True) Or (SelectionFont.Italic = True) Or > > (SelectionFont.Underline = True) Or (SelectionFont.Strikeout = True)) Then > > > > Return False > > > > Else > > > > Return True > > > > End If > > > > End Get > > > > Set(ByVal value As Boolean) > > > > Dim start As Integer = SelectionStart > > > > Dim length As Integer = SelectionLength > > > > For i As Integer = 0 To length - 1 > > > > SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, > > FontStyle.Regular) > > > > Next > > > > Me.Select(start, length) > > > > End Set > > > > End Property > > > > > > > > Private Sub SelStyle(ByVal _style As FontStyle, ByVal value As Boolean) > > > > Dim start As Integer = SelectionStart > > > > Dim length As Integer = SelectionLength > > > > For i As Integer = 0 To length - 1 > > > > Me.Select(start + i, 1) > > > > Dim style As FontStyle > > > > If value = True Then > > > > style = _style > > > > Else > > > > style = FontStyle.Regular > > > > End If > > > > If (SelectionFont.Italic And (FontStyle.Italic <> _style)) Then style = > > (style Or FontStyle.Italic) > > > > If (SelectionFont.Strikeout And (FontStyle.Strikeout <> _style)) Then style > > = (style Or FontStyle.Strikeout) > > > > If (SelectionFont.Bold And (FontStyle.Bold <> _style)) Then style = (style > > Or FontStyle.Bold) > > > > If (SelectionFont.Underline And (FontStyle.Underline <> _style)) Then style > > = (style Or FontStyle.Underline) > > > > SelectionFont = New Font(SelectionFont.FontFamily, SelectionFont.Size, > > style) > > > > Next > > > > Me.Select(start, length) > > > > End Sub > > > > End Class > > > > ------------------------------------------------------------------ > > > > > > > > > > > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > > news:euKBxOgjGHA.4660@TK2MSFTNGP03.phx.gbl... > > > "andreas" <andr***@pandora.be> schrieb: > > > >A selected text has fontstyles like bold and italic and underscore > > > > I want to remove one of them without changing the other fontstyles. > > > > How to do that? > > > > > > > > > Unfortunately there is no clean way to archieve that using the .NET > > > richtextbox control because of the rather awkward wrapper around the > > > character styles. However, you can use p/invoke with 'SendMessage' + > > > 'EM_SETPARAFORMAT' (see MSDN) instead. > > > > > > -- > > > M S Herfried K. Wagner > > > M V P <URL:http://dotnet.mvps.org/> > > > V B <URL:http://classicvb.org/petition/> > > > >
Error converting FILETIME to DateTime
Read text-segment from binary file line breaks is it possible to get delegates from properties directly? control types XML-RPC Tabindex is driving me nuts!!! richtextbox selectedtext bold upper .... how to find out actions done twice but only one trigger? Screen coordinates of selected datagridview cells left and top borders |
|||||||||||||||||||||||