Databind

  • Thread starter Thread starter Steven Licciardi
  • Start date Start date
S

Steven Licciardi

Hello,

Can someone tell me how to bind an element in a DataView to a
textbox.text property. I've tried :

aTextBox.DataBindings.Add("Text", aDataRowView_OfADataView, "AttrVal")

But this just returns an error (ArgumentException).

Thanks,

Steven

p.s. I can do : aTextBox.DataBindings.Add("Text", aDataView,
"AttrVal"), but this just binds to the AttrVal column of the first
row, when I would like to choose the row.
 
You don't bind a screen element to a row. Instead you bind it to a column
and then position BindingManagerBase(the object responsible for interface
between bound controls and datasets) to a particular row.

Binding bnd = aTextBox.DataBindings.Add("Text", aDataView, "AttrVal");
bnd.BindingManagerBase.Current = nRowIndex;

Note that this will affect other controls on this form that are bound to the
same data source
 
Thanks,

Steven

Alex Feinman said:
You don't bind a screen element to a row. Instead you bind it to a column
and then position BindingManagerBase(the object responsible for interface
between bound controls and datasets) to a particular row.

Binding bnd = aTextBox.DataBindings.Add("Text", aDataView, "AttrVal");
bnd.BindingManagerBase.Current = nRowIndex;

Note that this will affect other controls on this form that are bound to the
same data source
 
Back
Top