Here are some frequently asked questions about Windows Forms and their answers.
Browse by Tags
All Tags » Button (RSS)
-
|
public class RepeatButton : Button { private Timer timer1; public int Interval { get { return Timer.Interval; } set { Timer.Interval = value; } } private Timer Timer { get { if ( timer1 == null ) { // create and setup the timer timer1 = new Timer(); timer1...
|
-
|
Use the Button's public method PerformClick. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
You can use the Button.Image property to add an image to a button face. Use the Button.ImageAlign (and possibly Button.TextAlign) to layout your button face. You can also implement custom drawing on a button face as described in How do I add custom drawing...
|
-
|
Get a Graphics object for the button and use its MeasureString method to compute the width you need. using ( Graphics g = button1.CreateGraphics() ) float w = g.MeasureString( button1.Text, button1.Font ).Width; button1.Width = (int) w + 12; // 12 is...
|
-
|
Subclass Button and add a custom Paint event handler that does you custom drawing. public class CustomButton : Button { public CustomButton() { Paint += new PaintEventHandler( ButtonPaint ); } private void ButtonPaint( object sender, PaintEventArgs e...
|