A problem in master-detail with innerForm technology
-
mahmoodi_sm
- Posts: 3
- Joined: Sat 01 May 2010 06:40
- Location: IRAN
A problem in master-detail with innerForm technology
Dear Sir/ Madam,
I have a form with two master-detail grid that works correctly when SqlDataTables are in same form.
But when I link the grids to SqlDataTables in another form with innerForm Tecnology it does not work. When I move in master grid, detail grid does not change.
Best regards.
I have a form with two master-detail grid that works correctly when SqlDataTables are in same form.
But when I link the grids to SqlDataTables in another form with innerForm Tecnology it does not work. When I move in master grid, detail grid does not change.
Best regards.
-
StanislavK
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
-
mahmoodi_sm
- Posts: 3
- Joined: Sat 01 May 2010 06:40
- Location: IRAN
Thanks lot for your reply.
The form with the referenced data table is created before the form that display data.
I create a sample project with two form. Form2 for two master-detail SqlDataTables and Form1 for two DataGridViews.
In Form2 the ParentRelation property of sqlDataTable2 (detail table) is set to sqlDataTable1 and it's related fields.
This is significant code of Form2:
And in Form1 I write:
I run the program. Form1 was opened and data on Form1 are shown but moving on dataGridView1 (master grid) does not change the dataGridView2 (detail grid)'s data !
The form with the referenced data table is created before the form that display data.
I create a sample project with two form. Form2 for two master-detail SqlDataTables and Form1 for two DataGridViews.
In Form2 the ParentRelation property of sqlDataTable2 (detail table) is set to sqlDataTable1 and it's related fields.
This is significant code of Form2:
Code: Select all
partial class Form2
{
private void InitializeComponent()
{
. . .
this.sqlDataTable1.Connection = this.sqlConnection1;
this.sqlDataTable1.Name = "sqlDataTable1";
this.sqlDataTable1.Quoted = true;
this.sqlDataTable1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataTable1.TableName = "sqlDataTable1";
this.sqlDataTable1.Owner = this;
this.sqlDataTable2.Connection = this.sqlConnection1;
this.sqlDataTable2.Name = "sqlDataTable2";
this.sqlDataTable2.ParentRelation = new Devart.Common.ParentDataRelation(this.sqlDataTable1, new string[] {
"OrderID"}, new string[] {
"OrderID"});
this.sqlDataTable2.Quoted = true;
this.sqlDataTable2.SelectCommand = this.sqlSelectCommand2;
this.sqlDataTable2.TableName = "sqlDataTable2";
this.sqlDataTable2.Owner = this;
this.sqlConnection1.ConnectionString = "Data Source=.;Initial Catalog=crm_demo;Integrated Security=False;Password" +
"=1;Persist Security Info=True;User ID=sa;Application Name=\"dotConnect for" +
" SQL Server\";";
this.sqlConnection1.Name = "sqlConnection1";
this.sqlConnection1.Owner = this;
this.sqlSelectCommand1.CommandText = "select * from Orders";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Name = "sqlSelectCommand1";
this.sqlSelectCommand1.Owner = this;
this.sqlSelectCommand2.CommandText = "select * from [order Details]";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
this.sqlSelectCommand2.Name = "sqlSelectCommand2";
this.sqlSelectCommand2.Owner = this;
}
}
}
And in Form1 I write:
Code: Select all
public Form1(Form2 form2)
{
InitializeComponent(form2);
dataGridView1.DataSource = form2.sqlDataTable1;
dataGridView2.DataSource = form2.sqlDataTable2;
form2.sqlDataTable1.Open();
form2.sqlDataTable2.Open();
}
-
StanislavK
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
-
StanislavK
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
We have investigated the problem. The scheme you are interested in cannot be implemented using the Interform technology. The reason is that two different CurrencyManager objects are used on forms Form1 and Form2 for the master grid to master data table binding, and these CurrencyManager instances may point to different positions in master grid. As actually the instance on Form2 is used, changing of the selected row in the master grid will not affect the detail grid.
The only possible workaround is to place the master grid to the form where the master data table is located.
The only possible workaround is to place the master grid to the form where the master data table is located.
-
mahmoodi_sm
- Posts: 3
- Joined: Sat 01 May 2010 06:40
- Location: IRAN
-
StanislavK
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48