Problem visual control in vs2005

W

wavemill

Hello,

I would like herited of my button control and change my background.
I have try it, but my background is always grey.
Have you got an idea?

This is my code:

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

namespace ButtonControl
{
public partial class BeButton : System.Windows.Forms.Button
{
public BeButton()
{
InitializeComponent();
}

protected override void OnPaint(PaintEventArgs e)
{
Brush myBrush = new SolidBrush(Color.Blue);
Rectangle destinationRect = new Rectangle(0, 0, this.Width,
this.Height);
e.Graphics.FillRectangle(myBrush, destinationRect);
base.OnPaint(e);
}
}
}

Thank you for your help,

wavemill
 
P

Peter Foot [MVP]

As long as your device has .NETCF v1.0 SP2 or later the BackColor property
of your Button will change the button's background.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top