How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

Custom form background color

Winforms by default don’t offer much customization as far as coloring, especially when it comes down to gradient patterns.

If you want to change the background of your form to something a bit more unique to make it look like this

Custom form background
then simply follow steps below.

First handle the form’s Paint event.

Feel free to change the colors and the gradient direction to what you would like.

Then we need to make sure that our form is properly painted when the user resizes the form. In order to do that we will need to handle the form#s Resize event and Invalidate our form when it gets resized.

You will notice than when you resize the form some flickering happens. In order to eliminate that make sure to set your form’s DoubleBuffered to true either by simply changing the property in the property window or by calling this.DoubleBuffered = true; in your form’s constructor or in the Load event

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *