Bind control by stringnames

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear reader

I'm having a problem.
'How can I bind a control when I have the name of the control, name of the dataset and name of the field in table

strControl = "txtCustomerName
strDataset = "dsCustomers
strField = "Customer.CustomerName

This is the information I got. Normally I would bind a control in runtime like this

Me.txtCustomername.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.dsCustomers, "Customers.CustomerName")
But the strings can contain different controls each time

Thx..
 
Hi,
one way is the foreach ....


strControl = "txtCustomerName";

foreach(control ctrl in MyForm.Controls)
{
if(ctrl.Name==strControl)
{
// DO YA BIND;
}
}



--

Pavel KOHOUT
Advantage Solutions, Ltd.
www.advantages.cz




Maurice said:
Dear reader,

I'm having a problem.
'How can I bind a control when I have the name of the control, name of the
dataset and name of the field in table?
strControl = "txtCustomerName"
strDataset = "dsCustomers"
strField = "Customer.CustomerName"


This is the information I got. Normally I would bind a control in runtime like this:

Me.txtCustomername.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.dsCustomers,
"Customers.CustomerName"))
 
Back
Top