Home All Groups Group Topic Archive Search About
Author
21 Nov 2004 10:45 AM
Adrin
What makes TextBox so different from Button that this happens:

class FakeButton : Button
{
  public void DoFakePaint(PaintEventArgs e)
  {
     base.OnPaint(e);
  }
}

class UserControlClass : UserControl
{
  FakeButton fb;
  public  UserControlClass()
  {
     InitializeComponent();//.... standard stuff
     this.Paint += new PaintEventHandler(this.MyPaint);
     fb = new FakeButton();
     fb.Size = this.Size;
     fb.Text = "something";
   }

   private void MyPaint(object sender, PaintEventArgs e)
  {
     fb.DoFakePaint(e);
  }
}

This basically instructs the button to paint itself on the graphics for
UserControlClass.
What I want is to be able to do the same thing using TextBox & different
other complex controls.

I got it working for the simple ones like Label, CheckBox, Link... but
ListBox, ComboBox, TextBox don't draw anything (if I call
base.OnPaintBackground(e) in DoFakePaint all they do is paint a square with
the bg color but nothing else).

Is this possible? What makes the difference between these controls?

thx

AddThis Social Bookmark Button