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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

32791 Aug 8,2005 11:17 AM Aug 8,2005 01:36 PM Windows Forms 3
loading
Tags: GridControl
Ross Prestmo
Asked On August 8, 2005 11:17 AM

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.

Administrator [Syncfusion]
Replied On August 8, 2005 12:31 PM

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.

Ross Prestmo
Replied On August 8, 2005 01: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.

Administrator [Syncfusion]
Replied On August 8, 2005 01:36 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;