How can I minimize flickering when drawing a control

The Window.Forms framework offers support for double buffering to avoid flickers through ControlStyles. Double buffering is a technique that attempts to reduce flicker by doing all the drawing operations on an off-screen canvas, and then exposing this canvas all at once. To turn on a control’s double buffering, you need to set three styles. public UserPictureBox() //derived from System.Windows.Forms.Control { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // Activates double buffering SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); // TODO: Add any initialization after the InitForm call }

How do I use the ColorDialog to pick a color

It is straight-forward. Create an instance of the class and call its ShowDialog method. ColorDialog colorDialog1 = new ColorDialog(); //fontDialog1.ShowColor = true; if(colorDialog1.ShowDialog() != DialogResult.Cancel ) { textBox1.ForeColor = colorDialog1.Color; } textBox1.Text = ‘this is a test’;

How do I use the FontDialog class to set a control’s font

It is straight-forward. Create an instance of the class and call its ShowDialog method. FontDialog fontDialog1 = new FontDialog(); fontDialog1.ShowColor = true; if(fontDialog1.ShowDialog() != DialogResult.Cancel ) { textBox1.Font = fontDialog1.Font ; textBox1.ForeColor = fontDialog1.Color; } textBox1.Text = ‘this is a test’;

How do I set the font for a control

Use the Font property for the control along with the Font class in the System.Drawing class. button1.Font = new Font (‘Courier’, 10, FontStyle.Bold);

How do I use the system clipboard

The SetDataObject and GetDataObject methods in the Clipboard class found in the System.Windows.Forms namespace allows you to access the clipboard. Here is some code. string text = ‘Some text for the clipboard’; Clipboard.SetDataObject(text); //clipboard now has ‘Some text for the clipboard’ text = ”; //zap text so it can be reset… IDataObject data = Clipboard.GetDataObject(); if(data.GetDataPresent(DataFormats.Text)) { text = (String)data.GetData(DataFormats.Text); //text is now back to ‘Some text for the clipboard’ }