Change a webBrowser Background Color with colorDialog in C#

Change a webBrowser Background Color with colorDialog in C#

                                                                                                                                                           

in this c# tutorial we will see how to change a webBrowser control Background Color using C# .


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Csharp_And_MySQL
{
    public partial class WebBroser_Background_Color : Form
    {
        public WebBroser_Background_Color()
        {
            InitializeComponent();
        }

        private void BTN_COLOR_Click(object sender, EventArgs e)
        {

            DialogResult colors = colorDialog1.ShowDialog();

            if(colors == DialogResult.OK)
            {
                string colorCode = ColorTranslator.ToHtml(colorDialog1.Color).ToString();

                textBox_Color.Text = colorCode;

                webBrowser1.DocumentText = "<html><body style='background-color:"+colorCode+"'></body></html>";

            }
        }
    }
}



Share this

Related Posts

Previous
Next Post »