Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ControlPaint Class

Provides methods used to paint common Windows controls and their elements. This class cannot be inherited.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public sealed class ControlPaint
public final class ControlPaint
public final class ControlPaint

The methods contained in the ControlPaint class enable you to draw your own controls or elements of controls. You can control the drawing of your own controls if the UserPaint bit is set to true for the control. You can get or set the style bits by calling the GetStyle or SetStyle methods. You can set multiple style bits for any control. The ControlStyles enumeration members can be combined with bitwise operations.

The following code example uses one of the ControlPaint constructors to draw a flat Button control.

using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
      private Button button1 = new Button();
      private Button button2 = new Button();

    static void Main() 
        Application.Run(new Form1());

    public Form1(){
        this.button2.Location = new Point(0, button1.Height + 10);
        this.Click += new EventHandler(this.button2_Click);

    private void button2_Click(object sender, System.EventArgs e)
        // Draws a flat button on button1.

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;

public class Form1 extends Form
    private Button button1 = new Button();
    private Button button2 = new Button();

    /** @attribute STAThread()
    public static void main(String[] args)
        Application.Run(new Form1());
    } //main

    public Form1()
        this.button2.set_Location(new Point(0, button1.get_Height() + 10));
        this.add_Click(new EventHandler(this.button2_Click));
    } //Form1

    private void button2_Click(Object sender, System.EventArgs e)
        // Draws a flat button on button1.
            button1.get_Handle()), 0, 0, button1.get_Width(), 
            button1.get_Height(), ButtonState.Flat);
    } //button2_Click
} //Form1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.