Form1.cs 790 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsGDISolidBrush
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. Graphics ghs = this.CreateGraphics(); //创建Graphics对象
  21. Brush mybs = new SolidBrush(Color.Red); //使用SolidBrush类创建一个Brush对象
  22. Rectangle rt = new Rectangle(10, 10, 100, 100); //绘制一个矩形
  23. ghs.FillRectangle(mybs, rt); //用Brush填充Rectangle
  24. }
  25. }
  26. }