Answered by:
Control does not support transparent background colors,vb.net

Question
-
Hi,
Im not able to set transparent background colors to my form it gives error as
"Control does not support transparent background colors"
Please give me solution if any...
Thankx in advnce..
Thursday, July 24, 2008 6:19 AM
Answers
-
Hi Sreenath G V,
As the document says the BackColor property does not support transparent colors unless the SupportsTransparentBackColor value of System.Windows.Forms.ControlStyles is set to true. By default the SupportsTransparentBackColor value of a form is set to false. To enable set transparent color for a form, you can set the SupportsTransparentBackColor value to true by inheriting from standard form.
Code Snippetpublic partial class MyBaseForm : Form
{
public MyBaseForm()
{
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
}
}
Then you can use this base form as the base class instead of the standard form. This allows you set the transparent color to the form, but it won’t make the form transparent. To make a form transparent you can set the Form.TransparencyKey Property.
Best regards.
Rong-Chun ZhangWindows Forms General FAQs
Windows Forms Data Controls and Databinding FAQsMonday, July 28, 2008 3:53 AM
All replies
-
Hi Sreenath G V,
As the document says the BackColor property does not support transparent colors unless the SupportsTransparentBackColor value of System.Windows.Forms.ControlStyles is set to true. By default the SupportsTransparentBackColor value of a form is set to false. To enable set transparent color for a form, you can set the SupportsTransparentBackColor value to true by inheriting from standard form.
Code Snippetpublic partial class MyBaseForm : Form
{
public MyBaseForm()
{
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
InitializeComponent();
}
}
Then you can use this base form as the base class instead of the standard form. This allows you set the transparent color to the form, but it won’t make the form transparent. To make a form transparent you can set the Form.TransparencyKey Property.
Best regards.
Rong-Chun ZhangWindows Forms General FAQs
Windows Forms Data Controls and Databinding FAQsMonday, July 28, 2008 3:53 AM -
hello
Thanks for your reply......
Monday, July 28, 2008 5:04 AM -
Maybe this will help. Simple option that works
http://script-tricks.110mb.com/pages/vb.net/console_transparency.php
Thursday, January 8, 2009 11:47 PM -
Excellent solution
put it before InitializeComponent(); of form
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
Usually can be used in tandem with color picker
this.BackColor = colorDialog1.Color;
if (colorDialog1.ShowDialog() == DialogResult.OK) {
this.BackColor = colorDialog1.Color;
Util.gs_ThemeColor = colorDialog1.Color.Name;
}this.BackColor = Color.FromName(Util.gs_ThemeColor);
Parvez Ahmad Hakim
www.abobjects.com
- Proposed as answer by Ali Monsef Friday, January 20, 2012 7:55 AM
- Unproposed as answer by Ali Monsef Friday, January 20, 2012 7:55 AM
Friday, November 11, 2011 2:19 PM -
Hi,
Im not able to set transparent background colors to my form it gives error as
"Control does not support transparent background colors"
Please give me solution if any...
Thankx in advnce..
i have an idea
make your background = any color " Me.BackColor = Color.Red
then make TransparencyKey = BackColor
it's work for me :D
Friday, January 20, 2012 7:57 AM -
To notify, he was asking VB.Net not C#Saturday, April 27, 2013 4:24 AM