Databinding the second

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

Ilya Tumanov [MS]

I'm confused... I don't believe CF's Listview control supports data binding.

Also, I believe binding context is not shared across forms unless one form
is a parent of another.


Best regards,



Ilya



This posting is provided "AS IS" with no warranties, and confers no rights.



*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

Markward said:
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.
 
M

Markward

Ohh Sorry,

I mixed up the names. Of course I am binding to a ListBox-Component.

Sry
 
I

Ilya Tumanov [MS]

It's turned out to be a known issue fixed in NETCF V2.



In CF V1 all list controls (except for DataGrid) would ignore list changed
events from DataSource.

There's no good workaround, sorry. You might be able to extend ComboBox
class and override SetItemCore(int index, object value), but this is quite
messy.


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top