I'm trying to bind a TrackBar to an entity object of mine:
myBar.DataBindings.Add( "Value", imgConvData, "Quality" );
It seems simple enough, and the TrackBar does indeed pick up the value of
"Quality" when the DataBinding is first set. Unfortunately, changing the
value of the TrackBar (via sliding the thingie around) doesn't change the
value of "Quality" for some reason. If I bind to a TextBox, on the other
hand, everything works well.
Why won't the TrackBar binding work?
Nathan Baulch - 13 Oct 2004 13:39 GMT
> I'm trying to bind a TrackBar to an entity object of mine:
>
[quoted text clipped - 7 lines]
>
> Why won't the TrackBar binding work?
I was able to get it working when binding to a DataTable, but not with an
arbitary object like you seem to be doing.
When using the DataTable, it was necessary to call
CurrencyManager.EndCurrentEdit() on ValueChange, as follows:
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
trackBar1.DataBindings["Value"]
.BindingManagerBase.EndCurrentEdit();
}
However when trying this with an object (in which case a PropertyManager
would be used), it didn't work at all.
The weird thing is that both EndCurrentEdit() implementations are almost
identical when disassembling.
Have you tried EndCurrentEdit()?
Colin - 14 Oct 2004 05:09 GMT
Nathan,
Love ya! It worked for me.
Any word on the mechanics of why I need to call EndCurrentEdit for a
TrackBar when I don't with a TextBox?
I'm a web programmer, so this Windows stuff is still pretty new to me.
Nathan Baulch - 14 Oct 2004 07:20 GMT
> Any word on the mechanics of why I need to call EndCurrentEdit for a
> TrackBar when I don't with a TextBox?
I'm not sure. In my testing I needed EndCurrentEdit() for TextBoxes as well!
Colin - 14 Oct 2004 09:43 GMT
Weird.
Okay, now I have a new problem. I now have my property ("Height")
synchronized with the TrackBars, but the "Height" property is also bound to a
TextBox.
The problem: If I change the TextBox value, the TrackBar value will change
appropriately, but if I change the TrackBar, the TextBox doesn't get updated.
I communicate my class changes with an HeightChanged event as a tutorial
suggested (and actually both the TextBox and the TrackBar values get set if I
change "Height" programmatically), but the TrackBar isn't communicating
changes properly. Any ideas?