这里为了简单,没有扩展RadioButton实现重用。

  1. private void radioButton1_Paint(object sender, PaintEventArgs e) 
  2.     RadioButton rButton = (RadioButton)sender; 
  3.     Graphics g = e.Graphics; 
  4.     Rectangle radioButtonrect = new Rectangle(0, 0, 12, 12); 
  5.  
  6.     g.SmoothingMode = SmoothingMode.AntiAlias;//抗锯齿处理 
  7.      
  8.     //圆饼背景 
  9.     using (SolidBrush brush = new SolidBrush(Color.White)) 
  10.     { 
  11.         g.FillEllipse(brush, radioButtonrect); 
  12.     } 
  13.  
  14.  
  15.     if (rButton.Checked) 
  16.     { 
  17.         radioButtonrect.Inflate(-2, -2);//矩形内缩2单位 
  18.                 g.FillEllipse(Brushes.Red,radioButtonrect);  
  19.         radioButtonrect.Inflate(2, 2);//还原 
  20.     } 
  21.  
  22.     //圆形边框 
  23.     using (Pen pen = new Pen(Color.Red)) 
  24.     { 
  25.         g.DrawEllipse(pen, radioButtonrect); 
  26.     } 

图片:

 

C# Winform编程RadioButton重绘_职场