I have used VS2005 to create a strongly typed dataset by dragging and dropping onto my Windows Form. I then used TableAdapters & BindingSources in the designer to bind the data to my form.
I now want to create an instance of the DataSet programmatically, and be able to bind to that object at design time.
For example:
class Test { /*MyDataSet is a strongly typed DataSet created by the Win Forms designer.*/ private MyDataSet m_AppData = new MyDataSet(); public MyDataSet AppData { get return m_AppData; } } |
I am able to access the DataSet in the designer by going to Data Sources and adding a new object data source (in this case my Test object). I can see the DataSet within the Test object from the designer.
My problem is that the DataTables/DataColumns within the DataSet are not automatically exposed to the designer. It's the columns I need to drag and drop onto the form to data bind!
Do I have to do it all programmatically ie. Do I have to expose a property in my Test class for each DataTable and DataColumn in MyDataSet Or, do I need to manually type in lots of data binding code in my forms Load method Surely not - I suspect I'm missing something obvious.
Any help would be greatly appreciated.

Help! Design Time Databinding With DataSets in VS2005
bangorme
No - you're not missing anything. You can't using object data binding with a typed DataSet - you need to use instance based binding (you need an instance of the DataSet on the form).
One way to get this working is to drop an instance of MyDataSet and a BindingSource on the Form you are designing. Set the BindingSource.DataSource to the MyDataSet instance (at design time). Use the designer to bind your controls through the BindingSource. In your Form_Load (or equivalent), set the BindingSource.DataSource to the DataSet returned from the call to Test.AppData (e.g. MyBindingSource.DataSource = MyTest.AppData; ).
Joe Stegman
The Windows Forms Team
Microsoft Corp.
This posting is provided "AS IS" with no warranties, and confers no rights.
Colin Desmond