Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey Everyone!

 

I've read some of the other articles here about transparent controls, but none of them seem to apply to what I'm trying to do ... I am using a third party tab control that mimics the XP style tabs under any OS (check out http://www.ciatheco.com - awesome group of developers) ...

 

However, when I add a label and place it on top of the tab control (which has a gradient background) and set the backcolor to "transparent" it shows through the colour of the form?!

 

Should it not show through the item underneath?

 

HELP!!!

 

Thanks in advance!

M.

Posted

Well, I tried setting my desktop to 16-bit colour (had it set to 32-bpp) but that didn't work either .. here's a screenshot of what I'm trying to do ... See how the label1 appears grey (picks up the colour from the background) instead of the tab control ...

 

M.

  • Moderators
Posted

then this has nothing to do with TransparencyKey or 32 bit res.

 

It seems that setting the label to transparent does nothing. the only thing I can say is to set it's BG color to the same as the control.

 

You can download this Color Picker I made a while back, use the Eye-Dropper to grab the color of any object on your desktop.

Visit...Bassic Software
  • *Gurus*
Posted

This is surprisingly easy to do. At runtime, in your Form_Load, stick this:

 

Label1.Parent = PictureBox1

 

Replacing PictureBox1 with whatever the name of your tab control is. The label will then get its background from that, assuming its backcolor is set to transparent.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Thought of that .. LOL .. but it uses a gradient background so that doesn't work .. not sure how the gradient is "painted" on the form ... would it help to know?

 

M.

Posted
A quick update .. if I set the transparency key to "pink" and the background of the label to "pink" it DOES have an effect ... the label becomes white .. but it's still distinguishable from the background of the tab control ...
  • *Gurus*
Posted

I know it had a gradient background, and my way works. I tested it, putting my label in a picturebox with the screenshot you posted as a background.

 

Remember, you won't get the effect at design time, only at runtime after you set the .Parent property.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Divil,

 

I believe you ... it's just that it's not working for me?! Could it be because this control is an ActiveX and not a .NET control? Or could it be the way that the control is being "drawn" .. or (oh no!) maybe it's me!! LOL

 

Here's what I've done ... I've created an instance of this tab control, on it I've place a label 'Label1' ... I've sent the BackColor property to "Transparent" and in the Form Load event I've added the following code:

 

   Private Sub frmPatientRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       Label1.Parent = tabPatientRegistry

   End Sub

 

It still appears with the background grey ... if you want to test out what I mean, you can download the controls at http://ciatheco.com/Support/Patches_Main.asp ..

 

Thanks everyone for your help!

M.

Posted

In further playing around, I've gone back to the transparency key, and I realize now what was happening .. it's like cutting a hole through the form where the transparency is set. I create a form, drop the tabcontrol on it, create a label on top of the tabcontrol. I set the Transparency Key on the form to "Pink" and then set the BackColor of the label to "Pink" and when I run it my desktop shows through the "transparent" part of the label .. very strange .. but could create some neat effects ... I guess that's how odd-shaped forms are created .. :)

 

Learn something new every day!!! :)

 

M.

  • *Gurus*
Posted

I downloaded it but it says it's a trial version and wouldn't run at runtime. However at design time I did notice that it's not a control container, and the fact that it's an ActiveX control really doesn't help either.

 

I don't know what to suggest, apart from not using ActiveX controls :)

 

Robby, the parent was as you thought (Label1.Parent = PictureBox1)

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Ok ... what if I take a different venue? Is it possible to give the .net panel control a gradient background fill? I'm told it could be done by overriding the OnPaint event? Can anyone point me to some sample code on how to do this as I've never done this sort of thing before ..

 

Thanks!

M.

  • *Gurus*
Posted
   Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
       Dim b As Brush

       b = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Panel1.Height), Color.Red, Color.Green)
       e.Graphics.FillRectangle(b, Panel1.ClientRectangle)
   End Sub

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...