Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / September 2006

Tip: Looking for answers? Try searching our database.

embedding another control in an inherited usercontrol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PureCode - 15 Sep 2006 23:38 GMT
Hi,

I have a UserControl that inherits from the Label Control. I surpress any
drawing it normally does and draw my own Label by overriding the OnPaint.

The objective with my Label is to embed a TextBox as well, so, it'd be a
Label + TextBox in one. (Instead of having to use a Label and TextBox
seperately, it's, of course, also completely different looking than normal).

I cannot seem to get this done. It displays my self-drawn Label just fine,
including text but the TextBox i defined by "private TextBox EditBox = new
TextBox();" in the code (or dropped in the Component screen, no difference)
is nowhere to be found. I tried a "EditBox.Show();" after painting the
Label. Tried BringToFront() on it, Update(), Refresh, etc .. but the TextBox
is not showing up at all on top of the Label.

Any ideas? I'd hate to have to code an entirely custom TextBox from scratch
:)

Thanks,

Pure
Kevin Spencer - 16 Sep 2006 16:12 GMT
Create a new UserControl by inheriting System.Windows.Forms.UserControl. Add
a TextBox and Label to the Control. Expose the properties of the TextBox and
Label Controls as properties of the UserControl. No need to override OnPaint
or anything else.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.

> Hi,
>
[quoted text clipped - 19 lines]
>
> Pure
Özden Irmak - 16 Sep 2006 19:19 GMT
Hello Pure,

Just add your textbox to "Controls" collection of your derived "Label"
control in a proper place such as in it's constructer, that's all...

Regards,

Özden

> Hi,
>
[quoted text clipped - 19 lines]
>
> Pure
PureCode - 17 Sep 2006 20:37 GMT
Thanks Guys :)

It turned out to be pretty simple indeed.. but as usual i forgot to add
something in my code (i tend to forget to add things like Designers to
controls and then wonder for hours why the heck things aren't working)..
but, ala.. one learns every day and C# has me learning HARD, it's easy to
develop a decent application in C# but once you start going in-depth with
it, man, it starts causing headaches.

Pure

> Hello Pure,
>
[quoted text clipped - 29 lines]
>>
>> Pure

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.