M
Markward
Hi again,
I am back with my old question in a changed scenario.
As described before, I have som touble with updating a listView, that
has a bound table.
I'll try to describe the scen.:
For those who read my fist post: I changed from ArrayList to
DataSet+DataTable.
Form1 has a Listview and a button to open Form2
A DataTable is bound to the Form1-Listview.
Form2 has some Textboxes bound to the currently selected Element in the
Listview of Form1.
The Textboxes of Form2 are populated well with the DataTable bound to
the Listview. Changes made to the data in the textboxes are
communicated to the underlying DataTable, as I call
this.BindingContext[Global.patientenTable].EndCurrentEdit(); on
clicking on an ok button in Form2.
When closing Form2, bringing Form1 back to display, the changes have
not been reflected by the Listview, which still shows the old value of
the property recently changed.
I added a button to do some "brutal" refresh by setting the Listviews
DataSource to null an back to my Table again. Clicking this button
shows the correct new value of my property.
I am pretty desperate now, because I expected the ADO-Klasses to
implement the RefreshOnChange-kind-of functionality just by them
selves.
If I went wrong in that point, could someone plz tell me the preferred
pattern to cause refreshes to all Controls bound to a DataSource ? I
can'T believe, that I have to do many "null-settings" like described
above.
Here some codeexcerpts that may be of interest:
// Binding Data to Listview in Form1
this.listboxPatienten.DisplayMember = "name";
this.listboxPatienten.ValueMember = "uniqueId";
this.listboxPatienten.DataSource = Global.patientenTable;
this.listboxPatienten.SelectedIndex = -1;
// Binding the Textboxes in Form2
textboxName.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"name");
textboxForename.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"forename");
textboxStreet.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"street");
textboxPlz.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"plz");
textboxCity.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"city");
textboxUniqueId.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"uniqueId");
// Ending the edit-process in Form2
this.BindingContext[Global.patientenTable].EndCurrentEdit();
// My 'brutal' refresh
this.listboxPatienten.DataSource = null;
this.listboxPatienten.DisplayMember = "name";
this.listboxPatienten.ValueMember = "uniqueId";
this.listboxPatienten.DataSource = Global.patientenTable;
Hopefully someone can help.
I am back with my old question in a changed scenario.
As described before, I have som touble with updating a listView, that
has a bound table.
I'll try to describe the scen.:
For those who read my fist post: I changed from ArrayList to
DataSet+DataTable.
Form1 has a Listview and a button to open Form2
A DataTable is bound to the Form1-Listview.
Form2 has some Textboxes bound to the currently selected Element in the
Listview of Form1.
The Textboxes of Form2 are populated well with the DataTable bound to
the Listview. Changes made to the data in the textboxes are
communicated to the underlying DataTable, as I call
this.BindingContext[Global.patientenTable].EndCurrentEdit(); on
clicking on an ok button in Form2.
When closing Form2, bringing Form1 back to display, the changes have
not been reflected by the Listview, which still shows the old value of
the property recently changed.
I added a button to do some "brutal" refresh by setting the Listviews
DataSource to null an back to my Table again. Clicking this button
shows the correct new value of my property.
I am pretty desperate now, because I expected the ADO-Klasses to
implement the RefreshOnChange-kind-of functionality just by them
selves.
If I went wrong in that point, could someone plz tell me the preferred
pattern to cause refreshes to all Controls bound to a DataSource ? I
can'T believe, that I have to do many "null-settings" like described
above.
Here some codeexcerpts that may be of interest:
// Binding Data to Listview in Form1
this.listboxPatienten.DisplayMember = "name";
this.listboxPatienten.ValueMember = "uniqueId";
this.listboxPatienten.DataSource = Global.patientenTable;
this.listboxPatienten.SelectedIndex = -1;
// Binding the Textboxes in Form2
textboxName.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"name");
textboxForename.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"forename");
textboxStreet.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"street");
textboxPlz.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"plz");
textboxCity.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"city");
textboxUniqueId.DataBindings.Add("Text",Global.patientenListDlg.listboxPatienten.DataSource,"uniqueId");
// Ending the edit-process in Form2
this.BindingContext[Global.patientenTable].EndCurrentEdit();
// My 'brutal' refresh
this.listboxPatienten.DataSource = null;
this.listboxPatienten.DisplayMember = "name";
this.listboxPatienten.ValueMember = "uniqueId";
this.listboxPatienten.DataSource = Global.patientenTable;
Hopefully someone can help.