all groups > dotnet windows forms databinding > march 2005 >
You're in the

dotnet windows forms databinding

group:

Bind a data grid column to an element of a collection?


Bind a data grid column to an element of a collection? Paul Bartlett
3/18/2005 4:08:41 PM
dotnet windows forms databinding:
[Reposted here as probably more appropriate than
"microsoft.public.vb.controls.databound"]

Could anyone help with the following scenario?

- I have a class that exposes a collection (a Hashtable actually) as a
property.(called Custom).
- I am custom binding a WinForms DataGrid control to a collection of
instances of this class.
- I have discovered that I need to set the mapping name of the
DataGridTableStyle to that of the collection class (ArrayList in my case).
- I can bind columns to "simple" properties of the class by setting the
mapping name equal to the column name.
- What I'd like to do is bind a column to an element in the Hashtable. I
have tried various guesses at the syntax but none seem to work, e.g.:
Custom["Gender"], Custom.Item("Gender") and even just Custom.Gender.

Any ideas, or is this just not possible?

Thanks in advance,
Paul.

Re: Bind a data grid column to an element of a collection? Alexander Shirshov
3/20/2005 12:00:00 AM
Paul,

It's possible but... elaborate. Have a look at this thread:

http://discuss.develop.com/archives/wa.exe?A2=ind0502C&L=DOTNET-WINFORMS&P=R4310&I=-3

HTH,
Alexander


[quoted text, click to view]

Re: Bind a data grid column to an element of a collection? Paul Bartlett
3/21/2005 8:48:26 AM
Thanks for that, Alexander. I'd looked at this interface in the past, but
for some reason had got it into my head that the grid would not use it...

- Paul.

AddThis Social Bookmark Button