The exact code is at home, but it's basically set up like this (I'm just
typing this out, so it probably won't compile):
//***********entity class***********************
public event EventHandler HeightChanged;
public virtual void OnHeightChanged( EventArgs e )
{
if( HeightChanged != null )
HeightChanged( this, e );
}
private int height;
public int Height
{
get{ return Height; }
set
{
if( 0 < value || value <= 100 )
height = value;
else
thrown new ArgumentException( "value" );
}
}
//****************form********************
//initialization
myTrackBar.DataBindings.Add( "Value", myObj, "Height" );
myTextBox.DataBindings.Add( "Text", myObj, "Height" );
//event handler later
protected void myTrackBar_ValueChanged( ... )
{
myTrackBar.DataBindings["Value"].BindingManagerBase.EndCurrentEdit();
}
> Can you post some code?
>
[quoted text clipped - 19 lines]
> >
> > For more on what I'm doing, see my 10/13 post.
Sijin Joseph - 15 Oct 2004 04:35 GMT
Where are you firing the HeightChanged event when the height is changing?
try this
public event EventHandler HeightChanged;
public virtual void OnHeightChanged( EventArgs e )
{
if( HeightChanged != null )
HeightChanged( this, e );
}
private int height;
public int Height
{
get{ return Height; }
set
{
if( 0 < value || value <= 100 )
{
height = value;
OnHeightChanged(new EventArgs());
}
else
thrown new ArgumentException( "value" );
}
}
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
> The exact code is at home, but it's basically set up like this (I'm just
> typing this out, so it probably won't compile):
[quoted text clipped - 57 lines]
>>>
>>>For more on what I'm doing, see my 10/13 post.
Colin - 15 Oct 2004 08:59 GMT
Thanks again for the reply.
I actually DO fire the HeightChanged event when the Height property changes
in a manner similar to your example, I just forgot to add it in my hasty
typing (whoopsie).
I must emphasize that the event fires properly: a change to the TextBox will
be reflected by the bound TrackBar, and programatically setting the entity
property will cause BOTH the TextBox AND TrackBar to adopt the proper values.
The problem is that the TrackBar JUST ISN'T communicating its changes
properly and it's driving me nuts!!!
I keep trying work-arounds (using .EndCurrentEdit(), manually setting the
property in the TrackBar event handler, etc) but each presents new
coordination problems to overcome and that's something a DataBinding system
(that actually works) would solve.
I'm beginning to feel that this is just a Microsoft bug and have heard of
people having success moving each property to a collection then use THAT for
binding (which is wasteful, but if it works...) so I'm tempted just to throw
in the towel on the non-collection binding unless you (or the MSDN consierge)
have further input.
> Where are you firing the HeightChanged event when the height is changing?
>
[quoted text clipped - 90 lines]
> >>>
> >>>For more on what I'm doing, see my 10/13 post.