I normally program in C++, so all this DataSource/DataSet/Binding stuff is confusing the hell out of me. Hopefully you guys can help.
Basically I'm writing an editor for an XML-based file format (specifically, OFX, for financial data). I've used xsd.exe on my schema to deserialise loaded files into nice, plain old classes. I discovered DataGridView, which is brilliant, which I can just set its DataSource property to one of the collections I'm interested in (specifically, the list of transactions), and when I poke around with the values these changes get reflected in the loaded deserialised file, which I can then serialise out on save. But when I want to 'map' just a simple string to a TextBox (e.g. the account number), I can't use this clever method at TextBoxes don't seem to have a DataSource member... Using their 'Text' property just sets the text once and doesn't reflect changes back to the underlying object, so saving has to grab the values from the control first. I'd like it to be automatic like for the DataGridView.
I've tried fiddling with the DataBindings but I have no idea what to use as the propertyName or dataMember, so I'm not sure if that's what I'm meant to be using:
accountNumberTextBox.DataBindings.Add(new Binding("???", myDocument.accountNumber, "???");
Am I missing something really obvious? I hope so!