Referencing item on form with added to tab object as control

S

stmthomas

Hi,
I have an application where on the main form I have a tab control.
I also have created a form that has 2 text boxes and a couple of
buttons on it.
When the main form loads I run this code

Dim MyForm2 As New frmQuery
MyForm2.TopLevel = False
MyForm2.Show()
MyForm2.Dock = DockStyle.Fill
MyForm2.Anchor = AnchorStyles.Left
MyForm2.Anchor = AnchorStyles.Top
Me.TabControl1.TabPages(0).Controls.Add(MyForm2)
Me.TabControl1.TabPages(0).Controls(0).Anchor =
AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Right Or
AnchorStyles.Bottom
Me.TabControl1.TabPages(0).Controls(0).Dock = DockStyle.Fill
Me.TabControl1.TabPages(0).Focus()

This creates an instance of my form and adds it to the tab. This works
fine.

Now I want to load a file into on of the text boxes on the form
frmQuery. How do I reference it from the Main form??

I think I would start with

TabControl1.TabPages(TabControl1.SelectedIndex).Controls(0)......

but I'm not sure what goes next. Intellisence cannot pickup the
objects on frmQuery because it is loaded at runtime.

Does anyone have any ideas
 
F

FUnky

Hi,
I have an application where on the main form I have a tab control.
I also have created a form that has 2 text boxes and a couple of
buttons on it.
When the main form loads I run this code

Dim MyForm2 As New frmQuery
MyForm2.TopLevel = False
MyForm2.Show()
MyForm2.Dock = DockStyle.Fill
MyForm2.Anchor = AnchorStyles.Left
MyForm2.Anchor = AnchorStyles.Top
Me.TabControl1.TabPages(0).Controls.Add(MyForm2)
Me.TabControl1.TabPages(0).Controls(0).Anchor =
AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Right Or
AnchorStyles.Bottom
Me.TabControl1.TabPages(0).Controls(0).Dock = DockStyle.Fill
Me.TabControl1.TabPages(0).Focus()

This creates an instance of my form and adds it to the tab. This works
fine.

Now I want to load a file into on of the text boxes on the form
frmQuery. How do I reference it from the Main form??

I think I would start with

TabControl1.TabPages(TabControl1.SelectedIndex).Controls(0)......

but I'm not sure what goes next. Intellisence cannot pickup the
objects on frmQuery because it is loaded at runtime.

Does anyone have any ideas
could you please be a little more specific.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top