Well, I must say that his is a most surprising solution. Surprising because
it actually works!
It's even weirder however when I place another couple of controls on the
panel and set autoscroll to true. In this case, the background image from
the form scrolls with the panel but the same image stays put under the other
controls such as buttons.
As an experiment I placed a panel on the panel, this second panel had 100%
transparency and had a button on it. Although it flickers quite badly, the
panel and the button actually sroll around correctly over the form's
background. That's amazing!
I put the code after my sig.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace transpanelfromARGB
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
this.panel1.BackColor=Color.FromArgb(128,Color.Red);
this.panel2.BackColor=Color.FromArgb(0,Color.White);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.panel2);
this.panel1.Location = new System.Drawing.Point(80, 40);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(144, 168);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Controls.Add(this.button1);
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(500, 500);
this.panel2.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 88);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(568, 422);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
[quoted text, click to view] "Michael Powell" <michael@ramuseco.com> wrote in message
news:u6buaMVOGHA.428@tk2msftngp13.phx.gbl...
> Hi,
> Try setting your panel's background color to a Color.FromArgb
> you can the control the opacity by changing the alpha level.
>
> Hope this helps
>
> Mike Powell
> Ramuseco ltd
>
www.ramuseco.com > "S Chapman" <s_chapman47@hotmail.co.uk> wrote in message
> news:1140635263.665367.187650@g47g2000cwa.googlegroups.com...
>>
>> I don't seem to find Opacity property for a System.Windows.Forms.Panel
>> Control. How can I make a panel semi-transparent please?
>>
>
>