D
DLI
Scenario:
I have a form and two text boxes and one datagrid.
I have a dataset composed of two tables
Questions (QuestionID, QuestionText)
Answers (QuestionID, AnswerText)
there is a one to many relationship between Questions and Answers defined by
this Relation (QuestionAnswer) in the dataset ds
txtQuestionID is bound to a Questions.QuestionID
txtQuestion is bound to a Questions.QuestionText
this.txtQuestion.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionText");
this.txtQuestionID.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionID");
Datagrid named dgAnswers is bound to the relation QuestionAnswer
I have a move next button and a move previous button that sets the position
of the table questions forward and back.
The question and the txtQuestionID and txtQuestion change as they should
when I click the buttons.
Problem:
The datagrid displays the list of possible answers for the first question
only (correctly) when the form opens
When I click the next button, the text boxes both change but the datagrid
stays with the answers for the first question.
I have tried very syntax I can think of like:
this.dgAnswers.BindingContext = this.BindingContext;
this.dgAnswers.SetDataBinding(ds, "Questions.QuestionAnswer");
If I place another datagrid on the form and set its datasource to
this.dgQuestions.SetDataBinding(ds, "Questions");
and click a different question in this grid, the selection updates properly
in dgAnswers
How can I get the controls and the datagrid to use the same CurrencyManager?
I have a form and two text boxes and one datagrid.
I have a dataset composed of two tables
Questions (QuestionID, QuestionText)
Answers (QuestionID, AnswerText)
there is a one to many relationship between Questions and Answers defined by
this Relation (QuestionAnswer) in the dataset ds
txtQuestionID is bound to a Questions.QuestionID
txtQuestion is bound to a Questions.QuestionText
this.txtQuestion.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionText");
this.txtQuestionID.DataBindings.Add("Text", ds.Tables["Questions"],
"QuestionID");
Datagrid named dgAnswers is bound to the relation QuestionAnswer
I have a move next button and a move previous button that sets the position
of the table questions forward and back.
The question and the txtQuestionID and txtQuestion change as they should
when I click the buttons.
Problem:
The datagrid displays the list of possible answers for the first question
only (correctly) when the form opens
When I click the next button, the text boxes both change but the datagrid
stays with the answers for the first question.
I have tried very syntax I can think of like:
this.dgAnswers.BindingContext = this.BindingContext;
this.dgAnswers.SetDataBinding(ds, "Questions.QuestionAnswer");
If I place another datagrid on the form and set its datasource to
this.dgQuestions.SetDataBinding(ds, "Questions");
and click a different question in this grid, the selection updates properly
in dgAnswers
How can I get the controls and the datagrid to use the same CurrencyManager?