Can I use query-based master-detail relationship in the WPF application?
The problem is that OracleDataTable's Owner property accepts form that the component resides on. It seems like it accepts only WinForms - I cannot set it to C# class/WPF Window.
Is there an interface I could implement to make any C# class acceptable for the Owner property?
Query-based master-detail relationship and WPF
Shalex,
I'm trying to make all data binding manually.
I've tested query-based master-detail relationship using WinForms. I've put two data grids (DataGridView) on form and run example from documentation. Everything worked fine until I commented setting Owner properties. Detail grid is not showing any data when Owner properties are not set.
Do you now how can I make it work without setting Owner properties?
My source code:
OracleConnection connection = new OracleConnection("User Id=scott;Password=tiger;Server=orcl");
connection.Open();
OracleDataTable deptTable = new OracleDataTable("SELECT * FROM DEPT", connection);
OracleDataTable empTable = new OracleDataTable("SELECT * FROM EMP", connection);
empTable.ParentRelation.ParentTable = deptTable;
empTable.ParentRelation.ParentColumnNames = new string[] { "deptno" };
empTable.ParentRelation.ChildColumnNames = new string[] { "deptno" };
//deptTable.Owner = this;
//empTable.Owner = this;
deptTable.Open();
empTable.Open();
deptDataGrid.DataSource = deptTable;
empDataGrid.DataSource = empTable;
I'm trying to make all data binding manually.
I've tested query-based master-detail relationship using WinForms. I've put two data grids (DataGridView) on form and run example from documentation. Everything worked fine until I commented setting Owner properties. Detail grid is not showing any data when Owner properties are not set.
Do you now how can I make it work without setting Owner properties?
My source code:
OracleConnection connection = new OracleConnection("User Id=scott;Password=tiger;Server=orcl");
connection.Open();
OracleDataTable deptTable = new OracleDataTable("SELECT * FROM DEPT", connection);
OracleDataTable empTable = new OracleDataTable("SELECT * FROM EMP", connection);
empTable.ParentRelation.ParentTable = deptTable;
empTable.ParentRelation.ParentColumnNames = new string[] { "deptno" };
empTable.ParentRelation.ChildColumnNames = new string[] { "deptno" };
//deptTable.Owner = this;
//empTable.Owner = this;
deptTable.Open();
empTable.Open();
deptDataGrid.DataSource = deptTable;
empDataGrid.DataSource = empTable;
To make child table adjust its rows according to the current position in the parent table you should:
1. Set the ParentRelation property (ParentTable, ParentColumnNames and ChildColumnNames) of empTable.
2. Set deptTable.Owner = this. As a result, deptTable will track the events only from the specified Form.
Otherwise, you can use relations in DataSet for the same purpose.
1. Set the ParentRelation property (ParentTable, ParentColumnNames and ChildColumnNames) of empTable.
2. Set deptTable.Owner = this. As a result, deptTable will track the events only from the specified Form.
Otherwise, you can use relations in DataSet for the same purpose.
Thanks for reply.
My original problem was how to use query-based master-detail relationship in the WPF application. In WPF window I cannot set deptTable.Owner = this. I've created small WinForms example only to test, if Owner can be not set when I don't use design time features (like you suggested in previous reply).
Does it mean that query-based master-detail relationship works only with WinForms? If not, do you have an example how to use it in WPF?
My original problem was how to use query-based master-detail relationship in the WPF application. In WPF window I cannot set deptTable.Owner = this. I've created small WinForms example only to test, if Owner can be not set when I don't use design time features (like you suggested in previous reply).
Does it mean that query-based master-detail relationship works only with WinForms? If not, do you have an example how to use it in WPF?