DataBindings At "RunTime" Problems

  • Thread starter HAN(removethis)twister
  • Start date
H

HAN(removethis)twister

I've tried to create 11 textboxes as variables (not actually visible in
the program, not in Windows Form Designer) and have set DataBindings to
the text properties of the TextBoxes BUT according to tests I've run, it
says that the DataBindings exist, but the IsBinding is set to False, and
is ReadOnly (the bindings exist, they just aren't active AND I
can't/don't know how to make them active). Is there any way to allow
these 11 textboxes' text properties to have a DataBinding attached to it
at RunTime? Thanks for any help!
 
K

Ken Tucker [MVP]

Hi,

This is how to bind a textbox thru code.
TextBox1.DataBindings.Add("Text", ds.Tables(0), "myColumnName")



Ken
 
H

HAN(removethis)twister

HAN(removethis)twister said:
Different Columns in two different tables.
I created a textbox in the Form Designer with a DataBinder as reference,
copied the code to make the DataBinding to the Text Property, and edited
it for each textbox, and put this "code" in the Load event of the form.
My problem, as stated before, is that the IsBinding Property for some
reason is set to false, and I need it to be set to true.
 
C

Cor

Hi Han,

This is the only code you need to bind a textbox.

\\\code changed watch typos as sample
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"FirstName"))
textbox2.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
///
If you want to scroll up through it
\\\
CType(BindingContext(dataset1.Tables(0)), CurrencyManager).position += 1
///
,

I hope this helps,

Cor
 
H

HAN(removethis)twister

Cor said:
Hi Han,

This is the only code you need to bind a textbox.

\\\code changed watch typos as sample
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"FirstName"))
textbox2.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
///
If you want to scroll up through it
\\\
CType(BindingContext(dataset1.Tables(0)), CurrencyManager).position += 1
///
,

I hope this helps,

Cor
I've tried this, the IsBinding property is still set to false!
 
C

Cor

Hi Han,

Send some code, I am looking in the dark.

And please paste it first in a notebook, copy it then and paste it than in
this message because others it is mostly unreadable.

Cor
 
H

HAN(removethis)twister

Cor said:
Hi Han,

Send some code, I am looking in the dark.

And please paste it first in a notebook, copy it then and paste it than in
this message because others it is mostly unreadable.

Cor
Right Underneath "Windows Form Designer Code" Region:
Dim InvTxt(10) As TextBox

After Clear, Fill Commands in Form_Load Sub:
Dim num As Integer
For num = 0 To 10
InvTxt(num) = New TextBox
Next
InvTxt(0).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAccountMoney")
InvTxt(1).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerNameLast")
InvTxt(2).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerNameFirst")
InvTxt(3).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAddressLn1")
InvTxt(4).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAddressLn2")
InvTxt(5).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAddressLn3")
InvTxt(6).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAddressLn4")
InvTxt(7).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerAddressLn5")
InvTxt(8).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerUsesSalesTax")
InvTxt(9).DataBindings.Add("Text", C_DataSet1.Tables("Invoices"),
"InvoiceID")
InvTxt(10).DataBindings.Add("Text", C_DataSet1.Tables("Customers"),
"CustomerServAfterMonths")
Dim result As String
Dim result2 As String
For num = 0 To 10
result += InvTxt(num).Text & " "
result2 += Iif(InvTxt(num).DataBindings.Item("Text").IsBinding, "Yes",
"No") & " "
Next
MsgBox(result) 'result = " "
MsgBox(result2) 'result2 = "No No No No No No No No No No No "
(result's purpose: determine if any text is in textboxes. Result: FALSE)
(result2's purpose: determine if binded. Result: FALSE)
 
C

Cor

Hi Han,

May I see your select statements and your fill also, when there are by
instance case differences, it won't work.

This seems to me OK.

Cor
 
H

HAN(removethis)twister

Cor said:
Hi Han,

May I see your select statements and your fill also, when there are by
instance case differences, it won't work.

This seems to me OK.

Cor
Thanks for your time, a friend fixed my problem. (my Cable Internet was
down for the past couple of days, sorry It took so long to respond.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top