Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2004

Tip: Looking for answers? Try searching our database.

2-Way Binding to a TrackBar Not Working. What is my Problem?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin - 13 Oct 2004 08:05 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.