Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Error while increasing the font size. #1

Description

@blackaly

Hi bro. I was learning from your project, and I found a bug while increasing the font size from the increaseStripButton_Click().

Solution:

private void increaseStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                int size = Convert.ToInt32(richTextBox1.SelectionFont.Size) + 1;    // convert (fontSizeNum + 1)
                if (richTextBox1.SelectionFont == null)
                {
                    return;
                }
                // sets the updated font size
                richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont.FontFamily
                    ,size,richTextBox1.SelectionFont.Style);

                fontSizeComboBox.Text = size.ToString();    // update font size
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Information", MessageBoxButtons.OK, 
                    MessageBoxIcon.Warning); // show error message
            }
        }

Good luck!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions