After you change the text value you would need to invalidate the control to force a re-paint.
A better approach might be to use something like this:
Main Topics
Browse All TopicsI'm using vs2008 on vista. .Net's standard controls do not support transparency, so custom controls are necessary. At http://www.doogal.co.uk/tr
When I assign or change the value in the text property for the control, it does no show up on the design window; but after I run the program, it shows up. Similarly, when I change the value in the program, it does not show up.
So, something's missing from the control ... ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi BlearyEye;
To your question, "When I assign or change the value in the text property for the control, it does no show up on the design window", this may happen if the label is on top of another control and its z-order is not set to be the first. You can select the label control and right click on it. Then from the context menu select "Bring to Front".
To your question, "Similarly, when I change the value in the program, it does not show up", This may also be happening for the above reason but also that the system has not yet updated the UI. The simplest way to solve this issue is when you change the Text property of the label do it in a function as shown in the snippet this way you can force an update.
private void ChangeLableText(string changeTo)
{
transparentLabel1.Text = changeTo;
this.Invalidate(true);
}
Fernando
This doesn't directly answer the question - but I'm using VS2008 on Vista and I can quite succesfully set the background color of a label to Transparent and its working fine for me. When you say transparency is not supported - what do you mean? All the controls I've needed to have with a transparent background so far have worked fine.
mc-will: sorry, I missed that.
OK, I made the change and am closer since it now updates the text. However, there are some new issues.
1. The background that gets painted dynamically is wrong. There are several graphics on the form and it looks like the background chosen is part of another graphic that's a fair distance away from the label.
2. The previous text in the label is still there; it doesn't get erased when the new text is added.
3. In the designer, and until the first assignment in the program, the label shows up with a white background.
These are re-painting issues. Because the label is not painting it's background you need to have what ever is behind it invalidate the label retangle so that it repaints the background you want.
You could maybe do something cleaver in the OnPaintBackground override like:
this.Parent.Invalidate(thi
Hi BlearyEye;
Try this, leave your TransparentLabel class as originally posted that inherits from Control. When you add the TransparentLabel control to the form add its TextChanged event handler. Then in the event handler do the invalidate, like so:
private void transparentLabel1_TextChan
{
this.Invalidate(true);
}
Fernando
FernandoSoto:
The control is called ClipLength. I added the following to the form code as you suggested
private void ClipLength_TextChanged(obj
this.Invalidate(true);
}
I used the control as originally posted. This seemed to have no effect. I put a breakpoint on the code and it appears that the TextChanged method is never called. I'm changing the text from program code, not from user interaction.
I see what you did: changed the constructor to make the parent explicit.
It seems to be working now (yay), but I had to add the following:
To InitializeComponent:
this.ClipLength.TextChange
To the form class:
private void ClipLength_TextChanged(obj
this.Invalidate(true);
}
Otherwise, nothing happened.
I tried using this.ClipLength.Invalidate
The TransparentLabel control code includes a method InvalidateEx(). I added a breakpoint to the method and apparently it's never being called. I changed it to the attached snippet, but when I use this.ClipLength.Invalidate
Business Accounts
Answer for Membership
by: ToddBeaulieuPosted on 2009-07-29 at 08:38:45ID: 24971309
Hard to say, without working with that library, but drawing text like that on the design form is the responsibility fo the custom control, so it sure sounds like a bug in the library to me.