[02/03] Multiple Tab Pages with Copy of Master Form
Hi All,
VB.Net 02 and SQL2003
I do not know if this is possible, but it would be very efficient for recording group counseling sessions that could have up to 25 participants at a time.
Here what I would like to do:
On a form I have put a tab control client and added two tab pages.
On the first tab page which will act as the primary group configuration page I put a From Date and To Date text box, the Counselor ID text box, 3 Session number radio buttons, and finally a drop down combo box which will be used to select the multiple client consumers that has attended the group session.
On the second tab page I placed several text boxes which would serve as the master input form or template as it may be considered as.
After selecting the multiple clients on the drop down combo, I would like to load a tab page with a copy of the master form (template form) for each client selected so that the entry person can select back and forth between the few or many attendees and enter data.
Can it be done?
Re: [02/03] Multiple Tab Pages with Copy of Master Form
add a new tabpage for each client
vb.net Code:
Tabcontrol1.TabPages.Add("new tab")
then add new controls to each tabpage
vb.net Code:
Dim txtBx As New TextBox
Tabcontrol1.TabPages("new tab").Controls.Add(txtBx)
Re: [02/03] Multiple Tab Pages with Copy of Master Form
I think I am going to need some type of formatting to copy the main template tab page.
Re: [02/03] Multiple Tab Pages with Copy of Master Form
another way is to design a third tabpage, with the same controls as your main template tab page, and set visible = false.
then when you need a new tabpage
vb Code:
TabControl1.TabPages.Add(TabControl1.TabPages(2))
TabControl1.TabPages(TabControl1.TabPages.Count - 1).Text = "your text"
TabControl1.TabPages(TabControl1.TabPages.Count - 1).Show()
Re: [02/03] Multiple Tab Pages with Copy of Master Form
i'm assuming you don't want a combobox with all your clients listed on each clients tabpage?
Re: [02/03] Multiple Tab Pages with Copy of Master Form
The first tab page is the control of the Forms/TabPage it determines how many tab pages will be created.
The second tab page is the template of what I want to replicate onto other tab pages
Re: [02/03] Multiple Tab Pages with Copy of Master Form
this works in vb2005
vb Code:
TabControl1.TabPages.Add("your text")
TabControl1.TabPages(TabControl1.TabPages.Count - 1).Show()
For Each ctrl As Control In TabControl1.TabPages(1).Controls
Dim newCtrl As Control = Nothing
If TypeOf ctrl Is Label Then
newCtrl = New Label
ElseIf TypeOf ctrl Is TextBox Then
newCtrl = New TextBox
ElseIf TypeOf ctrl Is Button Then
newCtrl = New Button
End If
newCtrl.Top = ctrl.Top
newCtrl.Left = ctrl.Left
newCtrl.Text = ctrl.Text
TabControl1.TabPages(TabControl1.TabPages.Count - 1).Controls.Add(newCtrl)
Next
Re: [02/03] Multiple Tab Pages with Copy of Master Form
I used this, but it over writes tabpage2 and bombs out at about the 8th page added without throwing an error.
Code:
TabCtrlClient.TabPages.Add(TabPage2)
TabCtrlClient.TabPages(TabCtrlClient.TabPages.Count - 1).Show()
For Each ctrl As Control In TabCtrlClient.TabPages(1).Controls
Dim newCtrl As Control = Nothing
If TypeOf ctrl Is Label Then
newCtrl = New Label
ElseIf TypeOf ctrl Is TextBox Then
newCtrl = New TextBox
ElseIf TypeOf ctrl Is Button Then
newCtrl = New Button
End If
newCtrl.Top = ctrl.Top
newCtrl.Left = ctrl.Left
newCtrl.Text = ctrl.Text
TabCtrlClient.TabPages(TabCtrlClient.TabPages.Count - 1).Controls.Add(newCtrl)
Next
End Sub
Re: [02/03] Multiple Tab Pages with Copy of Master Form
don't use:
vb Code:
TabCtrlClient.TabPages.Add(TabPage2)
you're adding a new tabpage, then populating it with identical controls to TabPage2, not copying TabPage2
vb Code:
TabCtrlClient.TabPages.Add("new tabpage title")
Re: [02/03] Multiple Tab Pages with Copy of Master Form
That does not work in 02
Value of type 'String' cannot be converted to 'System.Windows.Form.Tabpage'
Re: [02/03] Multiple Tab Pages with Copy of Master Form
try adding a 3rd blank tabpage at design time, + setting .visible = false
then (check the overloads)
vb Code:
TabCtrlClient.TabPages.Add(TabPage3)
or
vb Code:
TabCtrlClient.TabPages.Add(index)
Re: [02/03] Multiple Tab Pages with Copy of Master Form
Is there a way to then Clone or Copy Tabpage 2?
Re: [02/03] Multiple Tab Pages with Copy of Master Form
no i don't think so. i'm using vb2005, but when i tried it the way you mean, it removed all the controls from tabpage2.
the only way i could get it working is to add a new blank page, then add new controls, identical to those on tabpage2
Re: [02/03] Multiple Tab Pages with Copy of Master Form
If there is not a clone command then there should be a procedure for copying the objects from a screen to another.
Create the tabpage, insert the objects.