博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

RadionButton 控件

Posted on 2011-07-17 17:57  itcfj  阅读(213)  评论(0编辑  收藏  举报

把多个radioButton 放在同一个容器中


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

namespace RadioButtonDemo
{
    public partial class Form1 : Form
    {
        private Color curColor;
        public Form1()
        {
            InitializeComponent();
        }

        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton radio = (RadioButton)sender;
            if (radio.Checked)
            {
                curColor = Color.FromName(radio.Text);
                Invalidate(false);
            }

        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            if (cbFill.Checked)
            {
                btnShow.BackColor = curColor;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

源码:WebCast20070601_Demo.zip