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 General / October 2004

Tip: Looking for answers? Try searching our database.

control data binding not happening when data entered from app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rua Haszard Morris - 14 Oct 2004 04:35 GMT
I have a textbox, which is bound to a class member:

textBoxDataServerhostname.DataBindings.Add("Text", localOptions,
"DataServerHostname");

The text can be entered by the user, or sometimes generated from code, for
example:
textBoxDataServerhostname.Text = anotherTextBox.Text;

When text is entered by the user, the class member is updated correctly;
when it's generated from code, the member is unchanged.

How do i get this to work (I want the member to change when the textbox is
changed from code)?

I have tried setting Modified = true, and setting ReadOnly = false (in the
case where the text is generated by code, the control is read only).

Thanks in advance for any help...
Sijin Joseph - 14 Oct 2004 04:46 GMT
Try adding this line of code after setting the text throught code

textBoxServerhostname.Bindings["Text"].BindingManagerBase.EndCurrentEdit();

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> I have a textbox, which is bound to a class member:
>
[quoted text clipped - 15 lines]
>
> Thanks in advance for any help...
Rua Haszard Morris - 14 Oct 2004 04:57 GMT
That has gotta be a record!  You win the prize!  Cheers...

for anyone reading this thread who is as paste-happy as
me:    textBoxDataServerhostname.DataBindings["Text"].BindingManagerBase.EndCurrentEdit();

So... anyone game to explain the underlying reason why this is the case?

> Try adding this line of code after setting the text throught code
>
[quoted text clipped - 23 lines]
> >
> > Thanks in advance for any help...
Rua Haszard Morris - 14 Oct 2004 05:07 GMT
Another less critical question...

All the controls on the form are bound like so:
textBoxDataServerhostname.DataBindings.Add("Text", localOptions,
"DataServerHostname");
numericUpDownPort.DataBindings.Add("Value", localOptions, "Port");
[etc]

Is there a way, (e.g.) when the form is closed, to EndCurrentEdit on all of
them? e.g.  something like:
Formclass.BindingContext.EndCurrentEdit()

Should I be setting up the bindings in a different way to make an operation
like that possible?

cheeeers again,
Rua HM.

> That has gotta be a record!  You win the prize!  Cheers...
>
[quoted text clipped - 30 lines]
> > >
> > > Thanks in advance for any help...
Sijin Joseph - 14 Oct 2004 05:49 GMT
Well the thing is, that the data gets sent to the source only when
EndCurrentEdit() is called. Typically this gets called in the
OnValidating() event of the control when you move focus away from the
control. Try moving focus away from the control and see if the data gets
commited, you may also use reflection to call the control.OnValidating()
method to get a similar effect.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> That has gotta be a record!  You win the prize!  Cheers...
>
[quoted text clipped - 30 lines]
>>>
>>>Thanks in advance for any help...

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.