ARTICLE

Set a Button State in VB.NET

Posted by Mahesh Chand Articles | VB.NET How do I May 19, 2010
This code snippet shows how to set a button state in Windows Forms.
 
Reader Level:

Button control has five states - Normal, Flat, Inactive, Pushed, and All. ButtonState enumeration represents a button state.

Windows Forms does not have a straight-forward way to set a button control state.

However, there is a way do to this J.

Windows Forms has a ControlPaint class with some static methods that can be used to draw various controls at runtime. The DrawButton method is used to draw a Button control and the last parameter of this method is ButtonState enumeration.

The following code snippet sets the button state of button1 using ControlPaint class.

ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(button1.Handle),

            0, 0, button1.Width, button1.Height, ButtonState.Pushed);

 

Here is the VB.NET code:

ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(button1.Handle),

            0, 0, button1.Width, button1.Height, ButtonState.Pushed)

 

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor