KeithWilliams
Registered User.
- Local time
- Today, 22:42
- Joined
- Feb 9, 2004
- Messages
- 137
Hi,
I have a form, Form_ValidateIncidents, which has a button that opens another form, Form_Property. The second form has a number of textboxes and other controls bound to a data source. I open the form in this case for the purpose of adding a new record. I want to initialise some of the values using code in the calling form.
So Form_ValidateIncidents has the following code:
Dim form_child As New Form_Property()
form_child.MdiParent = Me.MdiParent
form_child.Show()
form_child.OrgNameTextBox.Text = "ABC"
The application is an MDI, hence the setting of MDIParent, but I think that's irrelevant to my question. I'm setting the initial value to ABC to prove it works - there are a number of columns that need to be set, to various values derived from my calling form.
Form_Property has a DataSource, BindingSource and DataAdapter that were created using Visual Studio (not by my code). The Load event has the code:
Me.PropertyTableBindingSource.AddNew()
The problems are:
1. I can't set the Text of OrgName to "ABC" until after the form is visible, because the Load event on Form_Property does not fire until I call form_child.Show(). This could be a problem if performance is slow.
2. Surely I should be setting column values in the underlying DataAdapter (or DataSource or BindingSource?) rather than in the Text Box on the form? Otherwise I would have to change the code if I replaced the Text Box with a Combo Box or similar.
3. Is there a more object-oriented way to pass the initial values to the form?
As I said, I am currently working on how to add a new record to the database through this form. If its relevant, I also want to use this form later as the form for viewing and editing existing records.
Many Thanks,
Keith.
I have a form, Form_ValidateIncidents, which has a button that opens another form, Form_Property. The second form has a number of textboxes and other controls bound to a data source. I open the form in this case for the purpose of adding a new record. I want to initialise some of the values using code in the calling form.
So Form_ValidateIncidents has the following code:
Dim form_child As New Form_Property()
form_child.MdiParent = Me.MdiParent
form_child.Show()
form_child.OrgNameTextBox.Text = "ABC"
The application is an MDI, hence the setting of MDIParent, but I think that's irrelevant to my question. I'm setting the initial value to ABC to prove it works - there are a number of columns that need to be set, to various values derived from my calling form.
Form_Property has a DataSource, BindingSource and DataAdapter that were created using Visual Studio (not by my code). The Load event has the code:
Me.PropertyTableBindingSource.AddNew()
The problems are:
1. I can't set the Text of OrgName to "ABC" until after the form is visible, because the Load event on Form_Property does not fire until I call form_child.Show(). This could be a problem if performance is slow.
2. Surely I should be setting column values in the underlying DataAdapter (or DataSource or BindingSource?) rather than in the Text Box on the form? Otherwise I would have to change the code if I replaced the Text Box with a Combo Box or similar.
3. Is there a more object-oriented way to pass the initial values to the form?
As I said, I am currently working on how to add a new record to the database through this form. If its relevant, I also want to use this form later as the form for viewing and editing existing records.
Many Thanks,
Keith.