我想让我的粗体、斜体、下划线按钮在richtextbox 中相互配合。我找到了一个例子,但它在 c# 中。请帮助,它是如何在 C++ 中工作的:
if(e.Button==toolBarButton1)
{
int fStyle = (int)FontStyle.Bold + (int)FontStyle.Italic;
FontStyle f = (FontStyle)fStyle;
richTextBox1.SelectionFont =
new Font(richTextBox1.Font.Name, richTextBox1.Font.Size, f);
}
我的版本,我想重制它
if ( RichTextBox1->SelectionFont != nullptr )
{
System::Drawing::Font^ currentFont = RichTextBox1->SelectionFont;
System::Drawing::FontStyle newFontStyle;
if ( RichTextBox1->SelectionFont->Bold == true )
{
newFontStyle = FontStyle::Regular;
}
else
{
newFontStyle = FontStyle::Bold;
}
RichTextBox1->SelectionFont = gcnew System::Drawing::Font( currentFont->FontFamily,currentFont->Size,newFontStyle );