DataBinding objects in the Designer/GUI

D

dev

Hi everyone, Is there a way to bind a control (TextBox) to an untyped
public DataSet on a WinForm and have its columns appear in the designer
under "databindings"? For example, in pseudo-code:

public DataSet myDataSet = null; // could be exposed as a property
(...)

Form_Load(...)
myDataSet = AnotherClass.GetDataSet(primaryKey);

// All databindings are set in the designer

myDataSetBindingSource.DataSource = myDataSet; // Example

I'd be willing to describe the schema in "myDataSetBindingSource" or in
a drag-and-drop DataSet, etc, but I think setting the bindings in code
isn't the way it's done- I'm not stuck on using the GUI ;), just want a
standard to follow. Also, when I bind to an object or typed dataset,
where the schema is already exposed, everything works great. Thanks for
any suggestions!
 
F

Frans Bouma [C# MVP]

Hi everyone, Is there a way to bind a control (TextBox) to an untyped
public DataSet on a WinForm and have its columns appear in the
designer under "databindings"? For example, in pseudo-code:

public DataSet myDataSet = null; // could be exposed as a property
(...)

Form_Load(...)
myDataSet = AnotherClass.GetDataSet(primaryKey);

// All databindings are set in the designer

myDataSetBindingSource.DataSource = myDataSet; // Example

I'd be willing to describe the schema in "myDataSetBindingSource" or
in a drag-and-drop DataSet, etc, but I think setting the bindings in
code isn't the way it's done- I'm not stuck on using the GUI ;), just
want a standard to follow. Also, when I bind to an object or typed
dataset, where the schema is already exposed, everything works great.
Thanks for any suggestions!

THe designer has to know type information at design time, so it has
to know what columns the tables in the dataset have to give you the
ability to set the textbox' binding to one of these columns. As the
dataset's columns aren't known at design time in the construction
you're working with, you won't get the info at design time and have to
setup the bindings in code.

There's nothing wrong with setting up the bindings in code however.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top