Re: How to force binding on pressing toolbar button
- From: "RobinS" <RobinS@xxxxxxxxxxxxxxx>
- Date: Thu, 25 Jan 2007 14:22:10 -0800
Are you using a Binding Source? If not, you should consider it.
I use a BindingSource between my data and my controls, because
of all the features it offers.
You bind your BindingSource to your dataset, then bind your
controls to the BindingSource.
The Validate event is triggered when the user tabs to another
control, thus saving the data to the property of the control.
If you invoke the Validate yourself, it will take care of the
problem where they didn't tab out of it.
The EndEdit method pushes the data from the controls down into
the underlying data source.
This example uses a strongly typed dataset which has its own
table adapter with an Update method that persists the changes
from the data source to the underlying database.
If me.Validate() Then
m_CustomersBindingSource.EndEdit
m_CustomersTableAdapter.Update(m_NorthwindDataSet.Customers)
End If
Robin S.
---------------------------------------
"Andrus" <kobruleht2@xxxxxx> wrote in message
news:u55HlJvPHHA.2140@xxxxxxxxxxxxxxxxxxxxxxx
Robin,
thank you very much.
Where to find sample code for this ?
Andrus.
"RobinS" <RobinS@xxxxxxxxxxxxxxx> wrote in message
news:ZdOdnWizI-v0yCjYnZ2dnUVZ_oWdnZ2d@xxxxxxxxxxxxxx
In the event for that toolbar button, add a Validate() statement.
It will save any unfinished stuff in the control. Then do an
EndEdit() to push the data from the controls down into the data
source.
Then you have to update the data source.
Robin S.
-----------
"Andrus" <kobruleht2@xxxxxx> wrote in message
news:etQI2GmPHHA.1248@xxxxxxxxxxxxxxxxxxxxxxx
I noticed that when I change data in control bount to datatable
column and press Save button, data is not saved.
The problem is that pressing a ToolBar button does not cause the
ActiveControl to lose focus (same with menu items), thus not forcing
the control's value into it's databound object.
How to force binding for every control I can have in form: DataGrid,
TextBox, CheckBox, Commobox ?
This should be common WinForms issue.
Where to find generic solution about this ?
Andrus.
.
- References:
- How to force binding on pressing toolbar button
- From: Andrus
- Re: How to force binding on pressing toolbar button
- From: RobinS
- Re: How to force binding on pressing toolbar button
- From: Andrus
- How to force binding on pressing toolbar button
- Prev by Date: Re: Selecting a value in a ComboBox
- Next by Date: Re: Best charting package
- Previous by thread: Re: How to force binding on pressing toolbar button
- Next by thread: ToolStripControlHost, ToolStripDateTimePicker and ApplicationSettings
- Index(es):