Button 按钮的重绘

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

namespace BaseControl
{
    public partial class Room : Button
    {
        public Room()
        {
            InitializeComponent();
            Width = 100;//设置按钮的款度
            Height = 100;;//设置按钮的高度
        }

        public string str名称="";
        public string str姓名="";
        public bool b客房 = false;
        public bool b订房 = false;
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);

            pevent.Graphics.DrawString( str房间名称,new Font(FontFamily.GenericSansSerif,9),new SolidBrush(Color.Red),1,1);
            pevent.Graphics.DrawString(str姓名, new Font(FontFamily.GenericSansSerif, 9), new SolidBrush(Color.Red), 1, 15);

            if (b客房)
            {
                pevent.Graphics.DrawImage(Image.FromFile(@"D:\散客.gif"), 40, 40);
            }
            if (b订房)
            {
                pevent.Graphics.DrawImage(Image.FromFile(@"D:\预定.gif"), 60, 60);
            }
        }
    }
}

posted on 2010-04-15 19:30  guoxuefeng  阅读(1018)  评论(0编辑  收藏  举报