![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm having a tough time figuring out how to get the type that a binding source is bound to..at least in a consistant manner. What I have been doing is: (aBS is a BindingSource) Type aType = aBS.List.GetType(); if (aType.IsGenericType) { Type[] typeList = aType.GetGenericArguments(); mBoundType = typeList[0]; } This works most of the time. However, on occation, the type of the List is Object(!) not the type the designer set,i.e., this.userBindingSource1.DataSource = typeof(Model.User); At riun time the type of the list is Object. Anyone got any ideas? BP |
#3
| |||
| |||
|
|
Hi Bruce, The BindingSource.List property will be of BindingList<T> if you don't initialize it with a list as DataSource. If you don't initialize it with any object at all, the List will be a BindingList<System.Object BindingSource bs = new BindingSource(); //bs.List == List<System.Object |
#4
| |||
| |||
|
|
On Nov 4, 10:22 am, "Morten Wennevik [C# MVP]" MortenWenne... (AT) hotmail (DOT) com> wrote: Hi Bruce, The BindingSource.List property will be of BindingList<T> if you don't initialize it with a list as DataSource. If you don't initialize it with any object at all, the List will be a BindingList<System.Object BindingSource bs = new BindingSource(); //bs.List == List<System.Object The designer initializes a BS thusly: this.BindingSource1.DataSource = typeof(Model.User); This normally initializes the BS.ds to of BindingList<Model.User>; However, under certaim circumstaces, at run-time it's not; it's List<System.Object>. Weird. BP |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |