Click here to Skip to main content
15,847,653 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi masters,
excuse me because of the language,

i want to change the color of the form (gradient) for a while from low level of the color to the high , like a progress bar, almost like a splash screen, show the form & then hide it,
but i CAN'T :(

best wishes & dreams...
Updated 13-Sep-12 17:14pm
[no name] 7-Aug-12 20:27pm    
What does "but i CAN'T" mean exactly?
Sergey Alexandrovich Kryukov 7-Aug-12 20:57pm    
...and what is "gradiant"? :-)
The_Leader 7-Aug-12 22:30pm    
it mean's i cant :)
i want to have a gradient color instead of solid color for my form's backcolor...

tnx masters.

1 solution

Override the method Form.OnPaint. In this method, use the instance of System.Drawing.Graphics passed to you via the event argument parameters, and paint on the form using its method System.Drawing.Graphics.FillRectangle. For a brush, use a gradient brush System.Drawing.Drawing2D.LinearGradientBrush.

Please see:[^],[^].

Don't forget to dispose the objects which implement System.IDisposable. The best way of doing it and guarantee that it happens even if an exception is thrown, is using the using statement, which acts identically to the try-finally block:[^],[^].

You may face some flicker. You can eliminate it using double buffering for the form (or other control) where you do your custom rendering:[^].

Best wishes and wake-ups… :-)

Share this answer
The_Leader 7-Aug-12 22:31pm    
tnx master...
best wishes...
Sergey Alexandrovich Kryukov 8-Aug-12 0:06am    
You are welcome,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900