Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change binding source of text box

Status
Not open for further replies.

johnc83

Technical User
Jan 29, 2008
154
GB
Hi All,

could someone help me with a textbox binding problem please..

I have a textbox called JobNumberTextBox which is currently bound like this..

Code:
Me.JobNumberTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.MYSERVERTblJobsBindingSource, "JobNumber", True))

How do I get it to accept a variable in place of MYSERVER? For example if someone entered YOURSERVER in my ServerTextBox then I would like it to change to that..

I have tried the following but it doesn't work..
Code:
Me.JobNumberTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", "Me." & ServerTextBox.text & "TblJobsBindingSource, "JobNumber", True))

Can anyone point out where I am going wrong please..

Thanks

John


.NET 2.0, Visual Studio 2005, SQL Server 2005 Express
 
I'm going to say something that might get you buy until someone who deals with binding more than me might help.

Code:
Me.JobNumberTextBox.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.MYSERVERTblJobsBindingSource, "JobNumber", True))
The Me.MYSERVERTblJobsBindingSource is (for lack of a possible correct word) a bindable source not text. You would have to create the equivalent of that. I only did that once so I don't remember how, but if you look at the .designer.vb for the form you will see how they created it and you should be able to do the same. If I remember right that is how I did it.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Hi Sorwen, I understand now thanks for that.

So it is expecting a BindingSource rather than a string value.

I actually copied the code from the designer then tried to modify it to accept a string value.

So I think I just need to find out how to convert string to bindingsource now..

I'll take a look on google but if anyone can step in with the answer i'd appreciate it.

Thanks

John

.NET 2.0, Visual Studio 2005, SQL Server 2005 Express
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top