请问如何改变C#的winform的panel的指定区域的背景颜色
private void button1_Click(object sender, EventArgs e)
{
Graphics g = panel1.CreateGraphics();
弊弯 Point p1 = new Point(int.Parse(textBox1.Text),int.Parse(textBox5.Text));
Point p2 = new Point(int.Parse(textBox2.Text), int.Parse(textBox6.Text));
Point p3 = new Point(int.Parse(textBox3.Text), int.Parse(textBox7.Text));
携圆 Point p4 = new Point(int.Parse(textBox4.Text), int.Parse(textBox8.Text));
Point[] ps = new Point[4] { p1, p2, p3, p4 };
Brush b = Brushes.Red;
租隐闷 g.FillClosedCurve(b,ps);//可以换其他的东西来改变效果
}
不过form里的透明都是"假透明"
{
Graphics gp = panel1.CreateGraphics();
Rectangle rect = new Rectangle(new Point(1, 1), new Size(100, 50));
//gp.DrawRectangle(new Pen(Brushes.Red, 5f), rect); /埋正禅/弯尘清余线
gp.FillRectangle(Brushes.Red, rect); //填充
gp.Flush();
}
测试通过。