get the name of a form from a custom loaded control

  • Thread starter Thread starter Barkingmadscot
  • Start date Start date
B

Barkingmadscot

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
 
Barkingmadscot said:
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 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
 
Barkingmadscot said:
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

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