I want to use a combo box which contain some colors to change the background color of Windows Form?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jun 28, 2014, 11:21 AM
pen1 = new System.Drawing.Pen(cd.Color, 2F);
Joe WilsonPosted Jun 28, 2014, 2:43 PM
Joe WilsonPosted Jun 28, 2014, 9:42 AM
and mentioned does not take constructor that takes 2 arguments .Please check it.
VulpesPosted Jun 27, 2014, 7:41 PM
Joe WilsonPosted Jun 27, 2014, 12:50 AM
My code:
private System.Drawing.Graphics g;
private System.Drawing.Pen pen1 = new System.Drawing.Pen(Color.Blue, 2F);
private void butEllipse_Click(object sender, EventArgs e)
{
g = PictureBox1.CreateGraphics();
g.DrawEllipse(pen1, 50, 50, 100, 150);
}
private void butRectangle_Click(object sender, EventArgs e)
{
g = PictureBox1.CreateGraphics();
g.DrawRectangle(pen1, 30, 30, 50, 60);
}
VulpesPosted Jun 26, 2014, 10:55 AM
The colors are all shown in little boxes.
The user just has to select one and click OK.
Joe WilsonPosted Jun 25, 2014, 11:41 AM
VulpesPosted Jun 24, 2014, 2:28 PM
This has the advantage that the user can actually see what the colors look like. However, you're limited to a choice of 48 colors though another 16 'custom' colors can be added if you wish.
Here's how you'd show a ColorDialog on, say, a button click:
Joe WilsonPosted Jun 24, 2014, 12:50 PM
Joe WilsonPosted Jun 24, 2014, 12:43 PM
VulpesPosted Jun 24, 2014, 5:19 AM
Joe WilsonPosted Jun 24, 2014, 1:55 AM
VulpesPosted Jun 23, 2014, 2:59 PM