Using the Button Control in WinForms
C-Sharp Learning Part 3
The button control in WinForms can be customized way more than you think!
If you haven't seen the Part 2 of this series of C Sharp Learning, then click here
First, create a new project or use the Project we used in Part 2:
Then Drag a button into the Form:
To change the name of the Button: I will change the Name so that it is easy to use the Button with a name in our code:Next, to make the button look more modern:
To change the Back Color:
Just select the back color and change it to your desired color:
But there is still a gray border to it!
To change the border color or to remove the Border: Change the Flat Style to Flat
To Remove the Border: Expand the Flat Appearance property and select the BorderSize property and change it:
To Change the Font: Just select the Font property and click on the Three-Dots button:
To Change the ForeColor (Text Color): Just select ForeColor and choose your color:
To add a background image to the button: Just select the BackgroundImage property and click on the Three-Dots button. Clicking on it will pop a dialogbox, in the dialogbox and select the Local Resource option and click on Import:
As you can see the following screenshot shows the button with a light gradient background:
To change the layout of the image: Just select the BackgroundImageLayout:
To change the Text Align: Select the TextAlign Property and choose your alignment:
So these were few of the properties of a button control and you can try out the others as well if you want.
Thank you for reading this article! Hope this helps.
For the previous tutorial, click here
For the next tutorial, click here
Comments
Post a Comment