title: FontStyle code c# to c++
body: <p>I wanna to make my bold,italic,underline buttons work with eachother in richtextbox. I found an example, but its in c#. Help pls, how its works in c++:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>my version, I want to remake it</p>
  
  <pre><code>     if ( RichTextBox1-&gt;SelectionFont != nullptr )
     {
        System::Drawing::Font^ currentFont = RichTextBox1-&gt;SelectionFont;
        System::Drawing::FontStyle newFontStyle;
        if ( RichTextBox1-&gt;SelectionFont-&gt;Bold == true )
        {
           newFontStyle = FontStyle::Regular;
        }
        else
        {
           newFontStyle = FontStyle::Bold;
        }
        RichTextBox1-&gt;SelectionFont = gcnew System::Drawing::Font( currentFont-&gt;FontFamily,currentFont-&gt;Size,newFontStyle );
  </code></pre>