Petermcg001
asked on
Populate text box on tab page in tab control
Hello,
I have a data entry form with a tab control with a number of pages. On load my form populates a number of the text boxes. The problem is populating text boxes which are on the non-active tab page. Only the text boxes on the front page can be populated. For instance "EmailAddressTextBox.Text = .Item("EmailAddress")" only works if the EmailAddressTextBox.Text is on the first tab on on the main form itself.
Thank.
I have a data entry form with a tab control with a number of pages. On load my form populates a number of the text boxes. The problem is populating text boxes which are on the non-active tab page. Only the text boxes on the front page can be populated. For instance "EmailAddressTextBox.Text = .Item("EmailAddress")" only works if the EmailAddressTextBox.Text is on the first tab on on the main form itself.
Thank.
It works fine for me...VS2010 running on Win8.
All ten TextBoxes, one in each Tab, got populated from the Load() event:
All ten TextBoxes, one in each Tab, got populated from the Load() event:
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "1"
TextBox2.Text = "2"
TextBox3.Text = "3"
TextBox4.Text = "4"
TextBox5.Text = "5"
TextBox6.Text = "6"
TextBox7.Text = "7"
TextBox8.Text = "8"
TextBox9.Text = "9"
TextBox10.Text = "10"
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the above case if the CheckBox Is not DataBound the CheckState changes also in Form Load Event As Idle Mind said..
If it is...then it does not...
I think that this is because the Binding is initialized when a control is shown
Yiannis
If it is...then it does not...
I think that this is because the Binding is initialized when a control is shown
Yiannis
ASKER
Hello, thanks for looking at this.
Yes, it's correct that non-bound controls work on the load event but data bound controls do not. Populating the controls using the selectedindexchanged event approach works fine. You just have to put a check mechanism in place to prevent the textboxes being re-populated each time the user selects the tab page and changing any modifications they have made - I've taken a simplistic approach so I've added the following to the event:-
If TabControl1.SelectedIndex = 1 Then
If inttabpage1 = 1 then
' user has already selected tabpage so don't trigger repopulate.
else
'populate text boxes
inttabpage1 = 1
end if
thanks again
Yes, it's correct that non-bound controls work on the load event but data bound controls do not. Populating the controls using the selectedindexchanged event approach works fine. You just have to put a check mechanism in place to prevent the textboxes being re-populated each time the user selects the tab page and changing any modifications they have made - I've taken a simplistic approach so I've added the following to the event:-
If TabControl1.SelectedIndex = 1 Then
If inttabpage1 = 1 then
' user has already selected tabpage so don't trigger repopulate.
else
'populate text boxes
inttabpage1 = 1
end if
thanks again
The Controls in tabcontrol are created when the tabpage has focus...
use selecetedindex event to populate the EmailAddres TextBox...
John...