We help IT Professionals succeed at work.

How to get filling effects for a colour under Windows Forms?

Ahmet Ekrem SABAN
on
Medium Priority
342 Views
Last Modified: 2012-05-12
Hello!

I am involved in a C# Windows Forms project, where I am making the GUI. It is my first C# and Windows Forms project.

I have created several forms where I want to have a background colour with filling effects. The same is true for the buttons.

What I want is similar to that one can achieve with Microsoft Office applications, like Word, where you can add a drawing to a document over the menu "Insert" > "Graphic..." > "New drawing". You may change the colour of an object by clicking on it, then by clicking the right mouse button and selecting "Format AutoForm...", where the filling effects can be seen on the Color combo box (see the bottom of the colour list).

Thank you for your replies!
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2015

Commented:
What you want to do requires a lot of work. Something like the gradient is quite easy, but textures usually require a lot of work if you want to end up with smooth operations, and patterns force you to be at ease with drawing with your code.

Just the form that is needed for user selection can end up being quite an endeavour.

If this is for a library that you want to reuse and have plenty of time, you could go for it, but if it is for use in only on or two applications, the time needed is probably an overkill.

If I were you, I would look for a kit of components that have the feature already built-in. And the results might look a lot more professional than what you could achieve unless you already have a good experience in graphics and working with the GDI+ library that is used for drawings.

The price you would pay for that would probably be a lot less than what it would cost you in time. There are many sources for those collections of components.

ComponentOne has a good set at http://www.componentone.com/SuperProducts/StudioWinForms/. Infragistics are also appreciated by most of the programmers who use their controls. Another good place to look is ComponentSource. If it exists, they have it, and they often have prices that are lower than what you could get by going straight to the vendor's site.

I don't do textures and patterns in my work, but if you want I can send you some sample code for gradients. It's from a VB application, but the code is similar in C# since we use the same classes.
Ahmet Ekrem SABANSenior IT consultant

Author

Commented:
I am on vacation for a week.

I do not think that this much has to be spend for that, as I heard that a colleague here at our customer did it with Microsoft Visual Studio 2010. I will inform you, if it is true what I heard.
CERTIFIED EXPERT
Top Expert 2015

Commented:
Your colleague might have found some OpenSource components.

Personally, specially for my professional jobs, I shy away from those, because they are often buggy or incomplete, and I always fear maintenance problems the day where Microsoft decides to drop or change something that makes a component unusable.

Reputable vendors usually will make their best to develop controls that comply with Microsoft recommandations, and they are close enough to Microsoft that they have access to early builds of a new OS or a new version of VS, so they are ready to send you an update when you need one.
Senior IT consultant
Commented:
Hello!

Here is the kind of colouring I would like to have. The example uses the Microsoft Visual Studio withouth any installations of add-ins etc... Although nothing is written there about colouring, the button has a shaded appearance, which is what I wanted.

Cute button tutorial
Ahmet Ekrem SABANSenior IT consultant

Author

Commented:
I found the solution by myself on the Internet
CERTIFIED EXPERT
Top Expert 2015

Commented:
This is not a texture, this is a gradient.
Ahmet Ekrem SABANSenior IT consultant

Author

Commented:
That's correct! But I do not need any textures, but only a gradual change of colour from one to another.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.