Thanks for your answer.
I added BindingSource control to my Form. In the BindingSource control, the
DataSource only let me select an object such as the object of the Form and
not the BindingList I declared.
In the "Data Source Configuration Wizard" I selected an Object, the drop
down list of the "Select the Object You Wish to Bind to" only shows the
assemblies not the BindingList...
Thanks
Eitan
> If you mean List<T>, then absolutely... just set .DataSource =
> theList;
[quoted text clipped - 5 lines]
>
> Marc
Design-time binding (in the way you describe) can be done - all you
need to do is select the Type that you are interested in; so, if you
want to display a selection of Order objects in the grid, then select
(via the picker you mention) the Order class. This will generally
setup a BindingSource etc for you. Then, at runtime, you need to tell
it about your orders, so then you would set:
someBindingSource.DataSource = theList;
where theList could be anything suitable - a List<Order>,
BindingList<Order>, etc.
If you do the same entirely at runtime you can avoid having the
BindingSource in the mix, but this can sometimes be useful.
Marc
Eitan - 27 Jun 2007 05:18 GMT
Hello Marc,
Thanks for your answer.
Can a DataGridView that is bound to a class, say class ABC, that has more
data variables that I would like to show on the DataGridView:
For example, ABC has the variables: Var1, Var2, Var3 & Var4. I would like
the DataGridView to have only 2 columns that will be bound to Var2 & Var3 of
class ABC.
Thanks
Eitan
> Design-time binding (in the way you describe) can be done - all you
> need to do is select the Type that you are interested in; so, if you
[quoted text clipped - 12 lines]
>
> Marc
Marc Gravell - 27 Jun 2007 10:37 GMT
Yes; if using auto-generated columns, simply remove the ones you don't
need (you may need to turn off AutoGenerateColumns [or whatever]
afterwards).
If adding columns manually, simply don't add the ones you don't need.
Marc
Eitan - 27 Jun 2007 05:22 GMT
Marc,
The last question I asked can be asked also if instead of the class ABC we
would have a List or BindingList ABC?
Thanks
Eitan
> Design-time binding (in the way you describe) can be done - all you
> need to do is select the Type that you are interested in; so, if you
[quoted text clipped - 12 lines]
>
> Marc
Marc Gravell - 27 Jun 2007 10:40 GMT
Please clarify what you mean...
You can't really use a single instance of ABC as the DataSource [with
a grid] unless this is a collection itself (IList/IListSource) - but I
don't think this is what you were suggesting.
So you need to use *some* form of collection of ABCs - and List<ABC>
or BindingList<ABC> are common choices. But others would work.
However, at design time you must bind to the Type of ABC - you will
often see this in the Designer.cs as
"yourBindingSource.DataSource=typeof(YourNamespace.ABC);". This is a
feature of the IDE. If you don't use the IDE for binding you can omit
this step and bind just to the data.
Marc
Eitan - 27 Jun 2007 14:24 GMT
Hello Marc,
Thanks for your answer.
I do have a BindingList of this ABC and that is what I meant.
Eitan
> Please clarify what you mean...
>
[quoted text clipped - 12 lines]
>
> Marc