DataBinding change notification problem...

R

Richard

Hi,

I have a DateTime picker control on a form. The datetime
picker control is data bound to a column in a DataTable.
Yes I know about bound DateTime pickers and DBNull and
etc. so no troubles with that stuff...

However, as somebody out there probably knows,
programmatically setting the DateTimePicker.Value property
to a new VALUE does NOT in itself constitute a CHANGE to
the DataBinding mechanism {control focus etc. are involved
in the decision to fire change notification}.

Well this is causing me grief! I have a situation where I
MUST programmatically change the DateTimePicker.Value
property and I need the change to ripple down to my
DataRow immediately.

Question: How can I FORCE DataBinding change events to
fire for one or more bound controls on my form?

--Richard
 
J

J.Marsch

Richard:

Just a suggestion: you could try to take it the other way. Instead of
trying to programmatically modify the value of the datetime picker and have
it ripple down to the datarow, you could modify the underlying data field,
and let it "ripple up" to the control.

The trick would be getting to the current row. I think that it would go
something like this (haven't tested, this code might need some adjustment or
syntax correction):

// get the databinding object for the value property
Binding theBinding = theDateTimePicker.DataBindings["Value"];

// Get the current row
// if the target is a data row, I _think_ that you are going to get back a
// DataRowView object, but I might be lying.
DataRowView rowView = (DataRowView)theBinding.BindingManagerBase.Current;

// modify the value
rowView["TheColumnName"] = ANewDateTimeValue;
 
F

Frank Lakmann

Hello,

I'm having difficulties with the same problem in combination with the
DBNull issue. Can you explain the following a bit more, please? Do you
even have a solution for the DBNull-problem that works with databinding?
However, as somebody out there probably knows,
programmatically setting the DateTimePicker.Value property
to a new VALUE does NOT in itself constitute a CHANGE to
the DataBinding mechanism {control focus etc. are involved
in the decision to fire change notification}.

thanks in advance
Frank
 

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

Similar Threads


Top