Font Color Dialog

The main function of the color dialog box is to pop up the color palette that comes with the system, allowing users to choose a color or customize a color.

The main function of the font dialog is to select the font

Need to use the controls ColorDialog and Fontdialog components

   //change background color
        private void button1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog()==DialogResult.OK)
            {
                richTextBox1.BackColor = colorDialog1.Color;
            }
                    
        }
        // change font size
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (fontDialog1.ShowDialog() == DialogResult.OK)
                {
                    richTextBox1.Font = fontDialog1.Font;
                }
            }
            catch (Exception ex)
            {
                
                MessageBox.Show(ex.Message);
            }
            
        }

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324776667&siteId=291194637