Form Problem

B

BD

Moving from MS Access to .Net using C# languag. Problem trying to
duplicate form with structure as follows:
1. Main form 'Work Order' displayed as textboxes
2. subform 'Customers' textboxes showing name, address, etc related
by 'CustomerID'
3. subform 'Locations' textboxes showing name, address, etc related
by 'LocationID'
4. subform 'Material' on tabbed interface datasheet related by
'WorkOrderID'
5. subform 'Labor' on tabbed interface datasheet related by
'WorkOrderID'

Have successfully created child form "Work Order" with textboxes,
tabbed interface for 'Material' and 'Labor' records in datagrid views.
Problem is have been unable to present 'Customer' and 'Location'
information in textboxes on the form related tables.

Again, thank you in advance for any help.
 
G

Guest

BD napisał(a):
Moving from MS Access to .Net using C# languag. Problem trying to
duplicate form with structure as follows:
1. Main form 'Work Order' displayed as textboxes
2. subform 'Customers' textboxes showing name, address, etc related
by 'CustomerID'
3. subform 'Locations' textboxes showing name, address, etc related
by 'LocationID'
4. subform 'Material' on tabbed interface datasheet related by
'WorkOrderID'
5. subform 'Labor' on tabbed interface datasheet related by
'WorkOrderID'

Have successfully created child form "Work Order" with textboxes,
tabbed interface for 'Material' and 'Labor' records in datagrid views.
Problem is have been unable to present 'Customer' and 'Location'
information in textboxes on the form related tables.

Again, thank you in advance for any help.

Is the CustomerID and LocationID integers or strings ?. You can't
display integers directly in textbox, so it may be the reason.

best,
Slawomir
 
B

BD

SÅ‚awek said:
BD napisał(a):

Is the CustomerID and LocationID integers or strings ?. You can't
display integers directly in textbox, so it may be the reason.

best,
Slawomir

The CustomerID and LocationID are autonumber integers from a SQL
backend.
 
B

BD

RobinS said:
Are you using data binding? Are you using version 2003 or 2005?

Robin S.

I am using a remote server running MS SQL 2005 and visual studio pro
2005 for front end development. Yes, I am data-binding to the source.
However, my dataset nesting is not listing the subforms datatables in
the manner I am using them on this form. I think I will need to
develope a custom control to display this information but am unsure.
 
R

RobinS

BD said:
I am using a remote server running MS SQL 2005 and visual studio pro
2005 for front end development. Yes, I am data-binding to the source.
However, my dataset nesting is not listing the subforms datatables in
the manner I am using them on this form. I think I will need to
develope a custom control to display this information but am unsure.


Can you set up one dataset with all of the tables in it?
Because if you can do that, this should be a snap.

Let's say you can, and let's say you have \data_relations assigned
accordingly, you can bind the childgrids to the parent and
when the parent changes, the childgrids will show the children
that go with that parent.

Here's what you need:

A BindingSource for parent and each of the children.
I'm assuming parent = WorkOrderBindingSource,
children = WorkOrder_childBindingSource, like
WorkOrder_CustomerBindingSource.

Populate the dataset with all the tables. I'm assuming the
constraints are there; if they aren't, you can add them
to the dataset.

myDataSet.Relations.Add("WorkOrder_Customers",
myDataSet.Tables("WorkOrder").Columns("WorkOrderID"),
myDataSet.Tables("Customers").Columns("WorkOrderID"));

(do for all children)

Set up the databindings:

//parent
WorkOrderBindingSource.DataSource = myDataSet;
WorkOrderBindingSource.DataMember = "WorkOrder"; //name of table
WorkOrderIDTextBox.DataBindings.Add("Text", WorkOrderBindingSource,
"WorkOrderID"); //bind a text box; use the bindingsource
(etc)

//children

//set the binding source to the same one as the parent
WorkOrder_CustomerBindingSource.DataSource = WorkOrderBindingSource;

//set the datamember to the fk joining the tables
WorkOrder_CustomerBindingSource.DataMember = "FK_Customers_WorkOrder";

//set the data source on the child view to its own binding source
CustomerDataGridView.DataSource = WorkOrder_CustomersBindingSource ;

(do same for all children)

Run it.

I'm not a C# programmer, so if I missed any semi-colons or got any
brackets wrong, my apologies.

Robin S.
 
R

RobinS

RobinS said:
Can you set up one dataset with all of the tables in it?
Because if you can do that, this should be a snap.

Let's say you can, and let's say you have \data_relations assigned
accordingly, you can bind the childgrids to the parent and
when the parent changes, the childgrids will show the children
that go with that parent.

Here's what you need:

A BindingSource for parent and each of the children.
I'm assuming parent = WorkOrderBindingSource,
children = WorkOrder_childBindingSource, like
WorkOrder_CustomerBindingSource.

Populate the dataset with all the tables. I'm assuming the
constraints are there; if they aren't, you can add them
to the dataset.

myDataSet.Relations.Add("WorkOrder_Customers",
myDataSet.Tables("WorkOrder").Columns("WorkOrderID"),
myDataSet.Tables("Customers").Columns("WorkOrderID"));

(do for all children)

Set up the databindings:

//parent
WorkOrderBindingSource.DataSource = myDataSet;
WorkOrderBindingSource.DataMember = "WorkOrder"; //name of table
WorkOrderIDTextBox.DataBindings.Add("Text", WorkOrderBindingSource,
"WorkOrderID"); //bind a text box; use the bindingsource
(etc)

//children

//set the binding source to the same one as the parent
WorkOrder_CustomerBindingSource.DataSource = WorkOrderBindingSource;

//set the datamember to the fk joining the tables
WorkOrder_CustomerBindingSource.DataMember = "FK_Customers_WorkOrder";

//set the data source on the child view to its own binding source
CustomerDataGridView.DataSource = WorkOrder_CustomersBindingSource ;

(do same for all children)

Run it.

I'm not a C# programmer, so if I missed any semi-colons or got any
brackets wrong, my apologies.

Robin S.

One other thing -- if you have something other than a grid for
the children, you can bind those to their binding source.

CustomerNameTextBox.DataBindings.Add("Text",
WorkOrder_CustomerBindingSource, "CustomerName");

It's like magic!

Robin S.
 
B

BD

RobinS said:
One other thing -- if you have something other than a grid for
the children, you can bind those to their binding source.

CustomerNameTextBox.DataBindings.Add("Text",
WorkOrder_CustomerBindingSource, "CustomerName");

It's like magic!

Robin S.

You are correct, once I nested tables into the same dataset, everything
worked the way I wanted. Thank you very much for your help.

BD
 
R

RobinS

BD said:
You are correct, once I nested tables into the same dataset,
everything
worked the way I wanted. Thank you very much for your help.

BD

You're welcome; I'm glad it helped!

Robin S.
 

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