ControlPaint::DrawButton Method (Graphics^, Int32, Int32, Int32, Int32, ButtonState)
.NET Framework (current version)
Draws a button control in the specified state, on the specified graphics surface, and within the specified bounds.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: static void DrawButton( Graphics^ graphics, int x, int y, int width, int height, ButtonState state )
Parameters
- graphics
-
Type:
System.Drawing::Graphics^
The Graphics to draw on.
- x
-
Type:
System::Int32
The x-coordinate of the upper left corner of the drawing rectangle.
- y
-
Type:
System::Int32
The y-coordinate of the upper left corner of the drawing rectangle.
- width
-
Type:
System::Int32
The width of the button.
- height
-
Type:
System::Int32
The height of the button.
- state
-
Type:
System.Windows.Forms::ButtonState
A bitwise combination of the ButtonState values that specifies the state to draw the button in.
#using <System.dll> #using <System.Drawing.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Drawing; using namespace System::Windows::Forms; public ref class Form1: public Form { private: Button^ button1; Button^ button2; public: Form1() { button1 = gcnew Button; button2 = gcnew Button; this->button2->Location = Point(0,button1->Height + 10); this->Click += gcnew EventHandler( this, &Form1::button2_Click ); this->Controls->Add( this->button1 ); this->Controls->Add( this->button2 ); } private: void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { // Draws a flat button on button1. ControlPaint::DrawButton( System::Drawing::Graphics::FromHwnd( button1->Handle ), 0, 0, button1->Width, button1->Height, ButtonState::Flat ); } }; [STAThread] void main() { Application::Run( gcnew Form1 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: