We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Master-Detail (TextBox->Grid) and record navigation

Hi, I have created a master-detail windows form, where the master record is shown in textboxes, and the detail records are shown in a grid grouping control. I have got it working, but am a bit confused about something ... I have 1 dataset with two tables in it, and I create a DataRelation in code and assign the new relation as the DataMember of the grid [see below] (the datasource is set in the property palette). ********************************************* DataColumn parentCol; DataColumn childCol; parentCol = this.dataSet12.Tables["Dept"].Columns["DeptNo"]; childCol = this.dataSet12.Tables["Emp"].Columns["DeptNo"]; DataRelation relDeptEmp; relDeptEmp = new DataRelation("DeptEmp", parentCol, childCol); this.dataSet12.Relations.Add(relDeptEmp); this.gridGroupingControl1.DataMember = "DeptEmp"; this.oracleDataAdapter1.Fill(this.dataSet12,"DEPT"); this.oracleDataAdapter2.Fill(this.dataSet12,"EMP"); ************************************************* This all works fine; the confusing part comes when I created 2 buttons for navigating through the dataset ... I seem to have to set the dataset position twice (in two different ways) to get both the master and the detail to change (the following is from the "next" button): this.BindingContext[this.dataSet12,"DEPT"].Position += 1; this.BindingContext[this.dataSet12.DEPT].Position += 1; If I just have the first line, only the master will change, and if I just have the second line, only the detail will change. Is this the correct way to do this, or have I set something up wrong? Thanks for your help. Ross.

3 Replies

AD Administrator Syncfusion Team August 8, 2005 11:31 AM

You did not show how you were setting the grid.DataSource property or how you were doing the texbox.DataBindings.Add. If you want to just increment one currencymanager, then these two things must be set in a consistent manner to allow this. Otherwise, you would have to increment the different currencymanagers.


RP Ross Prestmo August 8, 2005 12:31 PM

Thanks for your reply. The generated code for setting the datasources is: this.gridGroupingControl1.DataSource = this.dataSet12.DEPT; and this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet12, "DEPT.DNAME")); I tried rewriting the code for the TextBox1 binding to use this.dataSet12.DEPT.DNAMEColumn, but couldn''t seem to get it to compile. Can you give me an example of how to do it? Thanks.


AD Administrator Syncfusion Team August 8, 2005 12:36 PM

Try changing the TextBox binding to: this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet12.DEPT, "DNAME"));

Loader.
Live Chat Icon For mobile
Up arrow icon