Click here to Skip to main content
13,002,169 members (75,872 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm looking for a focusable (can raise GotFocus and LostFocus event), borderless and transparent background control with text presentation. Do you know any already made one or a custom one?

Please don't suggest me the link to Alpha blend transparent textbox (right in CodeProject), I've tried it and it's not fine enough (the rendered text looks worse than lacking of antialiasing). I don't find any control for that purpose except the RichTextBox with over ridden CreateParams. But I don't want to use RichTextBox, it's not light weight and even using it, I have to customize some event-related methods...

Your help would be highly appreciated!
Posted 17-Apr-13 7:08am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Suddenly there is a thought springing in my mind which helps me solve this. I can't believe there is such a simple solution.

The control I want is a very common control for customization. It's called UserControl. I tested it with a label added to a UserControl's Controls and set the label's Dock to DockStyle.Fill, set the text to any thing I want, set the UserControl's BackColor to Color.Transparent and wowww, it worked. I thought of drawing string myself but wondered how it gets and loses focus? UserControl is exactly what I want...

Thank God!
supernorb 17-Apr-13 14:02pm
There are many questions about Focusable Label??? And here, this is a good start point to create your own Focusable Label. It's so simple. Ha ha
Dave Kreskowiak 17-Apr-13 14:30pm
and wowww, it worked. No, it didn't! You have the illusion it worked. Transparent in Windows Forms just tells the control to take on the background settings of the control that's hosting your control. If you put another control behind your control, you won't see it!

Transparent in Windows Forms is a complete lie. Why? Because the top control over a region of pixels OWNS all of the pixels it covers. When controls underneather your control are told to paint themselves, they are excluded from painting the pixels where your top level control sits.
supernorb 18-Apr-13 8:16am
Sorry Dave Kreskowiak, I don't want it to be so real transparent. I only want it to be transparent to the background of the parent not to anything behind it. And I said it worked, it's not illusion.
supernorb 18-Apr-13 8:19am
Thank you Dave Kreskowiak, anyway I would like to thank you because you let me know the real transparency in WPF, that has encouraged me more to visit the world of WPF. And I would like to accept your answer for that. Thanks =)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Sure. You can get an entirely library of such controls. Drop Windows Forms and use WPF. You get all the rendering options you could ever want.
supernorb 17-Apr-13 13:42pm
I love Windows Forms so much, don't want to get rid of it, and I'm sure to say I will love WPF for its features I can benefit from. But I'm asking this question for a solution in Windows forms, Oh WPF is my new world of programming windows. =))

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100