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 / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

get the name of a form from a custom loaded control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Barkingmadscot - 05 Mar 2008 12:12 GMT
I having problem get the of a form

here is the code to create the form and load my custom control (from a
button click)

       Dim MatForm As New Form
       Dim NewMatList As New MatListSelection

       MatForm.Size = New Size(395, 218 + btnExit.Height)
       MatForm.StartPosition = FormStartPosition.CenterParent
       MatForm.ShowInTaskbar = False
       MatForm.FormBorderStyle = FormBorderStyle.None

       NewMatList.Dock = DockStyle.Top

       MatForm.Controls.Add(NewMatList)
       MatForm.TopMost = True
       MatForm.Show()

The control fucntion fine

only when i come to dispose of the control, i want to dispose of the
form too

i have try

console.writeline(me.controls.parent.name.tostring)
console.writeline(me.controls.owner....

I get either the name of my control or blank

and many other ways i can think of

I am more than likely missing something

thank in advance

cheers
Armin Zingler - 05 Mar 2008 13:07 GMT
> I having problem get the of a form
>
[quoted text clipped - 19 lines]
> only when i come to dispose of the control, i want to dispose of the
> form too

I wouldn't do this! Controls, including Forms, will do a cascading
dispose of the contained controls.

> i have try
>
> console.writeline(me.controls.parent.name.tostring)
> console.writeline(me.controls.owner....

I don't understand this code. What is "Me"? Is this code inside your
control class or inside the Form?

> I get either the name of my control or blank
>
> and many other ways i can think of
>
> I am more than likely missing something

I cannot even compile it because the Controls collection does not have a
parent or owner property.

Armin
Herfried K. Wagner [MVP] - 05 Mar 2008 20:59 GMT
"Barkingmadscot" <barry@bcc-it.co.uk> schrieb:
> only when i come to dispose of the control, i want to dispose of the
> form too
[quoted text clipped - 5 lines]
>
> I get either the name of my control or blank

\\\
Dim ParentForm = Me.FindForm()
...
///

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>


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.