Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / August 2005

Tip: Looking for answers? Try searching our database.

PropertyDescriptorCollection.Add() - Method Not supported?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Mifsud - 20 Jul 2005 10:37 GMT
Hello,

I am attempting to implement a custom collection and wish to databind it to
a datagrid.
Currently I can successfully bind the data, but all the properties in my
custom object appear in the grid.
I wish to hide some of the columns.
I have been advised that to do this I need to provide a
PropertyDescriptionCollection with the columns that I require in the
GetProperties implementation of my custom collection.
However, although I can iterate through the custom objects properties
perfectly when I try and add or remove items from the collection I receive a
'Method Not Supported' exception.

Here is my code:

Dim pd As PropertyDescriptor
Dim t As New clsTecBE_Product
Dim pdc As PropertyDescriptorCollection
pdc = TypeDescriptor.GetProperties(t)
For Each pd In pdc
   If pd.Name.ToString <> "ProductionEnd" Then
       pdc.Remove(pd)          'Method not Supported' Exception fires here
   End If
Next

Any ideas on why?

Many thanks for any help,

Nick
Mitch Denny - 06 Aug 2005 08:55 GMT
Your collection needs to implement ITypedList. When you implement
GetItemProperties you return your own PropertyDescriptorCollection. When you
do this you can use the DataGrid Table and Column styles to hide certain
properties in the designer. You don't need to restrict what
PropertyDescriptors are returned, you just need to return them so that the
data-binding engine knows what it is binding to - you are almost there :)

Signature

Mitch Denny
email:  mitch.denny@notgartner.com
mobile: +61 (414) 610-141
blog:   http://notgartner.com
skype:  callto://mitchdenny

> Hello,
>
[quoted text clipped - 29 lines]
>
> Nick

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.