RobertoFreemano
asked on
open form2, TabPage 10... winform VB.NET 2003
Hi Experts,
I have 2 winforms
Form1 has 1 button... if clicked, it opens form2
Form2 has TabControl1 with xx tab pages...
I want Winform1 button to open winform2 and go direct to TabPage10.
Hope that makes sense?
Thanks,
Roberto
I have 2 winforms
Form1 has 1 button... if clicked, it opens form2
Form2 has TabControl1 with xx tab pages...
I want Winform1 button to open winform2 and go direct to TabPage10.
Hope that makes sense?
Thanks,
Roberto
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
more specfic...
Private WithEvents f2 As Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If f2 Is Nothing Then
f2 = YourFormNAme
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterScreen
f2.ShowDialog()
End Sub
Private Sub f2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles f2.FormClosing
f2 = Nothing
End Sub
'In Form2 Load event
Me.TabControl1.SelectedTab = TabPage10
ASKER
Hi jtoutou,
I tried:
Form2.TabControl.SelectedT ab = TabPage10
Error Message = "Name 'TabPage10' is not declared"
I tried:
Form2.TabControl.SelectedT
Error Message = "Name 'TabPage10' is not declared"
do you have tabpage10?
ASKER
Hi jtoutou,
Page didn't refresh in time :(
will try your code :)
Page didn't refresh in time :(
will try your code :)
ASKER
Couple of errors :(
f2 = Form2 .. Error = 'Form2 is a type and cannot be used as an expression'.
Me.TabControl1... error = 'TabConrtol1' is not a member of 'WindowsApplication.Form1'
f2 = Form2 .. Error = 'Form2 is a type and cannot be used as an expression'.
Me.TabControl1... error = 'TabConrtol1' is not a member of 'WindowsApplication.Form1'
Me.TabControl1.SelectedTab = TabPage10 You will put this code in the form load event (the form opened with the button click ...not the form1..The form that contains the tabcontrol)
in the button click event set:
If f2 Is Nothing Then
f2 = New Form2
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterSc reen
f2.ShowDialog()
in the button click event set:
If f2 Is Nothing Then
f2 = New Form2
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterSc
f2.ShowDialog()
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry jtoutou,
I cannot follow instructions for toffee ;(
Form 1 - button1 click event =
If f2 Is Nothing Then
f2 = YourFormNAme
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterSc reen
f2.ShowDialog()
Form2 = Load event = Me.TabControl1.SelectedTab = TabPage10
I get an error on Form1 = [f2 = New Form2]
&
[ If f2.WindowState = FormWindowState.Minimized Then]
---error------------------ ---------- ----------
An unhandled exception of type 'System.NullReferenceExcep tion' occurred in WindowsApplication1.exe
Additional information: Object reference not set to an instance of an object
I cannot follow instructions for toffee ;(
Form 1 - button1 click event =
If f2 Is Nothing Then
f2 = YourFormNAme
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterSc
f2.ShowDialog()
Form2 = Load event = Me.TabControl1.SelectedTab
I get an error on Form1 = [f2 = New Form2]
&
[ If f2.WindowState = FormWindowState.Minimized Then]
---error------------------
An unhandled exception of type 'System.NullReferenceExcep
Additional information: Object reference not set to an instance of an object
Try @idle's code is much more simple
Hope it Helps:)
'This is In Form1
Private WithEvents f2 As Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If f2 Is Nothing Then
f2 = YourFormNAme
End If
If f2.WindowState = FormWindowState.Minimized Then
f2.WindowState = FormWindowState.Normal
End If
f2.StartPosition = FormStartPosition.CenterScreen
f2.ShowDialog()
End Sub
Private Sub f2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles f2.FormClosing
f2 = Nothing
End Sub
'This is In Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TabControl1.SelectedTab = TabPage10
End Sub
f2= new Form2
ASKER
Either code showed errors, so I combined Idle_Minds code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f2 As New Form2
Form2.Show()
End Sub
with jtoutou's code:
Me.TabControl1.SelectedTab = TabPage10
now it works ;)
Thanks Guys
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f2 As New Form2
Form2.Show()
End Sub
with jtoutou's code:
Me.TabControl1.SelectedTab
now it works ;)
Thanks Guys
Glad i helped you Robberto!
ASKER
Dim form2 as new Form
Form2.TabContol1...... get lost here
:(