Click here to Skip to main content
Click here to Skip to main content

AlphaGradientPanel, an extended panel

By , 24 Mar 2006
 

Introduction

This is a panel, first of all. Therefore, it has all the advantages of a panel, plus some nice little features.

Using the code

You'll just have to include the component in your toolbox and use it.

The only property that is a bit special is the Colors() property. It is a collection of items and has design-time visibility in the property grid. I'm still trying to achieve transforming the color name that appears in the property grid in a nice drawing... If anybody knows how that can be achieved, please, please, please, let me know ;)

Features

  • Rounded corners (any one of them or all at the same time).
  • Gradients (from 2 to n colors, with some special effects).
  • Transparency (any color can be made transparent with an "Alpha" value between 0 and 255).
  • Borders, even with rounded corners, have a nice little border.
  • Image inclusion (position, opacity, size, grayscale, and padding).
  • Padding of the content, of the back, and of the docking.

History

  • Version 1.0.

License

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

About the Author

Nicolas Wälti
Software Developer (Senior)
Switzerland Switzerland
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
AnswerRe: Adding an AlphaGradientPanel at runtime?memberNick Waelti1 Oct '08 - 1:10 
Hello,
 
I did a quick test on my side (with VS 2008), and I can do that seamlessly:
(Code on Form Load)
 
Dim agp As New AlphaGradientPanel
agp.Size = New Size(100, 50)
agp.Location = New Point(50, 150)
Dim c1 As New ColorWithAlpha
c1.Color = Color.Red
Dim c2 As New ColorWithAlpha
c2.Color = Color.Yellow
agp.Colors.Add(c1)
agp.Colors.Add(c2)
Me.Controls.Add(agp)
 
Is that not working on your side ?
 
Cheers,
Nick
 
http://www.blueactivity.com

Questiontransparency over controlsmemberFallakka13 Aug '08 - 23:06 
Hi, i needed this to cover a whole form and have it semi transparent and show something on it, in a way that the whole form including the controls remains slightly visible. the problem im getting is that although i set the alpha levels and all, the controls are not visible through the panel... is there a way to do this? thanks
GeneralTransparency problemmemberzuraw13 Mar '08 - 4:06 
I compiled your demo application, and everything is working fine except transparency. I can't see components under AGPanels, because their background is the same color as the main form (standard way of interpreting Transparent color in .NET). How can I obtain effect shown on image in your article (see image under AGPanel)? I am using VS2008 under Windows XP.
GeneralRe: Transparency problemmembercdebel26 Feb '09 - 9:49 
I've the same problem! I'm using Windows XP with VS2005.
 
I don't know if its because i use Windows XP that i can't see anything transparent.
 
It would be nice if the person who published this code could give us a hint...
 
-----
Chris

QuestionExceptionmemberBBWicked31 Jul '07 - 23:46 
Hi,
your control is the best I have seen and used for a long time.
But I get an exception when I resize my main form on which are MANY nested AGPanels.
I can reproduce the failure if I resize the main window to a minum and the then back.
Or sometimes it happens just after minmizing and maximizing the window.
 

Here is a snippet of the exception(the part within double quotes I translated from german to english"):
 

System.NullReferenceException: "Object reference was not specified on an object instance."
at BlueActivity.Controls.AlphaGradientPanel.AlphaGradientPanel_Paint(Object sender, PaintEventArgs e)
at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion)
at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle)
...

 
Could you please help me to fix that bug, because I'm using your control on a project at work?
 
Best regards
BBWicked
Generalsorry but :)memberdeltadirac29 Jul '07 - 8:05 
i am a newbie so sorry to ask questions like this but i tried to reference the alphagradientpanel.dll it says ok and i can see it in the references then i built the application but anyway i coludn't see it on my toolbar (i am using vb.net 2005).
QuestionRemoving a colormemberthe-rpd1 Jul '07 - 5:20 
I'm using the code in a other project to modify it and get a nice button but i'm having a problem.
 
How can i delete a color?
 
I'm trying to delete it in design mode but it won't disapear from the color list and I'm getting an error.
When I delete it in de disigner generated code it's gone but I don't think thats the way it should be done?
When I re add the color in the designer I get the same error (something about component not being serializable).
Did I forget to copy something?
 
Also when I re add it in the designer code, I can set the color but the colorproperty above it gets the same color.
 
When I do this in your default project it all works fine.
GeneralNice controlmemberthe-rpd26 Jun '07 - 9:38 
Very nice!
 
Maby you could explain a bit more of what you did to get this great result.
Just like many more did with their projects on the code project.
Or perhaps you could add soms comment to the code or even only to the properties.
 
It will help al lot of coders who do not "yet" have great coding knowlage.
 

Thanks for sharing this with the world Smile | :) 5/5!
 
Raymond
GeneralRe: Nice controlmember(Nick Waelti)28 Jun '07 - 0:11 
Thanks Raymond,
 
I promise I will try to comment my code more. But currently, I'm on vacation and I don't have access to my system and I won't be able to do anything from here. Perhaps you could try to explain what you don't understand and I could give you a hint ?
 
Cheers,
Nick
GeneralRe: Nice controlmemberthe-rpd28 Jun '07 - 6:40 
It's not one thing, i'm interested in all of the code.
Especialy the alpha blending.
 
I'n starting to learn that basics of GDI now, but understanding this is hard withoud some comment.
So thats why I postet this suggestion, not only for my selfe but also for all other "beginners" who come by this nice peace of code.
 
If I'm going to understand exactely what you've don, then maby I could make a control with the same feature(s) my selfe.
 
If I'm having specific questions I'll ask.
 
Thanks for the re!
 
Raymond

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 24 Mar 2006
Article Copyright 2006 by Nicolas Wälti
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid