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 / January 2006

Tip: Looking for answers? Try searching our database.

Can i create control that add another control to container?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mtczx232@yahoo.com - 30 Jan 2006 21:39 GMT
I try to create Inherit TextBox ,that when i put it on the form,
it put also Label into the form. but how i can add the label to form
within
TextBox New method(constructor)?

have a way to do that, for designed time or at least for runtime?
Tim Wilson - 30 Jan 2006 21:47 GMT
Assuming the reason that the Label must be added to the form when the custom
TextBox is added is due to a relationship between the two controls, then you
may want to build a UserControl that contains both the TextBox and the Label
and define the relationship that way.

Signature

Tim Wilson
.NET Compact Framework MVP

> I try to create Inherit TextBox ,that when i put it on the form,
> it put also Label into the form. but how i can add the label to form
> within
> TextBox New method(constructor)?
>
> have a way to do that, for designed time or at least for runtime?
mtczx232@yahoo.com - 30 Jan 2006 22:39 GMT
>>build a UserControl that contains both the TextBox and the Label
i dont like this solution for some reasons. you are sure that not
posible
to put the label directly on the form? not at run time nor at design
time?

heare same code that i try, but is not work at all:
==============================
Imports System.Windows.Forms

Public Class Atext
   Inherits TextBox

   Public l As Label

   <System.Diagnostics.DebuggerNonUserCode()> _
   Public Sub New(ByVal Container As System.ComponentModel.IContainer)
       MyClass.New()

       'Required for Windows.Forms Class Composition Designer support
       Container.Add(Me)
       Container.Add(l)
   End Sub

   <System.Diagnostics.DebuggerNonUserCode()> _
   Public Sub New()
       MyBase.New()

       l = New Label
       l.Width = 600
       l.Height = 50
       l.Text = "llllllll"
       l.Visible = True
       l.Location = New Point(0, 0)

       'This call is required by the Component Designer.
       InitializeComponent()

   End Sub

   'Component overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub

   'Required by the Component Designer
   Private components As System.ComponentModel.IContainer

   'NOTE: The following procedure is required by the Component
Designer
   'It can be modified using the Component Designer.
   'Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       components = New System.ComponentModel.Container()
   End Sub
End Class
Tim Wilson - 30 Jan 2006 22:57 GMT
You can easily place a Label on the parent at runtime by overriding the
OnParentChanged method of the TextBox and adding a new Label to the parent
using the Parent property of the TextBox.

Signature

Tim Wilson
.NET Compact Framework MVP

> >>build a UserControl that contains both the TextBox and the Label
> i dont like this solution for some reasons. you are sure that not
[quoted text clipped - 57 lines]
>     End Sub
> End Class

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.