-
Manual Data Binding
Well, I thought for sure I could figure this out on my own, but that's what I get for thinking. I get a DataSet from a web service, and want to bind some form objects to it. Do the regular next, previous, add new etc. Here's what I've got so far:
Code:
private void Call_Load(object sender, System.EventArgs e)
{
ds = wsMain.GetTable("vActiveCalls");
tbORI.DataBindings.Add("Text", ds.Tables[0], "ORI");
tbCallNumber.DataBindings.Add("Text", ds.Tables[0], "Call_Number");
}
private void btnNext_Click(object sender, System.EventArgs e)
{
bmb = tbCallNumber.BindingContext[ds, "vActiveCalls"];
bmb.Position += 1;
}
During the form's Load method, things seem to work fine, my text boxes show the data from the first record. When I click btnNext, the position changes, but the text box values don't change. I keep thinking I'm missing something basic, but can't figure it out.
Any info appreciated,
Mike
-
I could have sworn I already posted a reply, but it didn't show up. This works ok:
Code:
private void btnNext_Click(object sender, System.EventArgs e)
{
tbCallNumber.DataBindings[0].BindingManagerBase.Position ++;
}
I guess I thought you could do it once, and not once for each control.
Edit: You only have to do it once, as changing the position of BindingManagerBase affects all controls.