Vince, I think i will make those properties as private which are not to be made available to the outside world ORElse If I still want those public property on the ITEM of the collection I think I will have to use some mechanism to hide those not required columns on the grid. I have not yet checked this!!!
Regards, Girish Jain ----- Original Message ----- From: "Vince P." <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, November 23, 2004 10:54 AM Subject: Re: [ADVANCED-DOTNET] Binding Custom Collections to WinForms DataGrid > Be careful about properties which your classes may have that don't > necessarily have to be seen by users. You can't easily pick and choose > which ones are bound. > > CC 1A 5B 94 D0 75 09 B4 > USA USA USA USA USA > http://hp6000.vinnychi.com/vince > Did you think that I was gonna give it up to you? > > > > -----Original Message----- > > From: Unmoderated discussion of advanced .NET topics. > > [mailto:[EMAIL PROTECTED] On Behalf Of Girish Jain > > Sent: Monday, November 22, 2004 11:10 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [ADVANCED-DOTNET] Binding Custom Collections to > > WinForms DataGrid > > > > Thanks Ranjan, > > > > It worked. It requires public properties to display on the grid. > > > > Thanks & Regards, > > Girish Jain > > > > >From: Ranjan <[EMAIL PROTECTED]> > > >Reply-To: "Unmoderated discussion of advanced .NET topics." > > ><[EMAIL PROTECTED]> > > >To: [EMAIL PROTECTED] > > >Subject: Re: [ADVANCED-DOTNET] Binding Custom Collections to WinForms > > >DataGrid > > >Date: Mon, 22 Nov 2004 20:04:18 +0530 > > > > > >I think you need to create public properties for each column > > you want to > > >show on the DataGrid. > > >So try to make _Name and _Dept public proerties and check. > > >r. > > > > > >-----Original Message----- > > >From: Unmoderated discussion of advanced .NET topics. > > >[mailto:[EMAIL PROTECTED] On Behalf Of Girish Jain > > >Sent: Monday, November 22, 2004 7:50 PM > > >To: [EMAIL PROTECTED] > > >Subject: [ADVANCED-DOTNET] Binding Custom Collections to > > WinForms DataGrid > > > > > >Hi All, > > > > > >I am having problem in binding a custom collection to a > > DataGrid. I have > > >created a collection and binding it to the DataGrid but it > > does not show > > >data on the grid. The code executes without any errors. I > > know I am missing > > >(probably a lot of things!), that's why I seek your help. > > Here's the code.. > > > > > >Public NotInheritable Class Employee > > > Private _Name As String > > > Private _Dept As String > > > > > > Public Sub New(ByVal Name As String, ByVal Dept As String) > > > Me._Name = Name > > > Me._Dept = Dept > > > End Sub > > > > > > Public Overrides Function ToString() As String > > > Return String.Format("Employee Name : {0} And > > Department is {1}", > > >Me._Name, Me._Dept) > > > End Function > > >End Class > > > > > > > > >Public NotInheritable Class EmployeeCollection > > > Inherits CollectionBase > > > > > > Public Function Add(ByVal obj As Employee) As Integer > > > Return MyBase.InnerList.Add(obj) > > > End Function > > > > > > Public Sub Remove(ByVal obj As Employee) > > > MyBase.InnerList.Remove(obj) > > > End Sub > > > > > > Default Public Property Item(ByVal index As Integer) As Employee > > > Get > > > If index > MyBase.InnerList.Count - 1 OrElse > > index < 0 Then > > > Throw New ArgumentOutOfRangeException("The specified > > >argument is out of range") > > > End If > > > Return DirectCast(MyBase.InnerList(index), Employee) > > > End Get > > > Set(ByVal Value As Employee) > > > MyBase.InnerList(index) = Value > > > End Set > > > End Property > > >End Class > > > > > > > > >This is the code I wrote in form > > > > > > Dim a As New EmployeeCollection > > > a.Add(New Employee("John", "Accounts")) > > > a.Add(New Employee("John", "Accounts")) > > > > > > dgTest.DataSource = a > > > > > > > > >Thanks in advance > > > > > >Regards, > > >Girish Jain > > > > > >_________________________________________________________________ > > >The Citi Rupee Checking Acct. Send money home free! > > >http://creative.mediaturf.net/creatives/citibankrca/rca_msnte > > xtlinks.htm > > >Get > > >fabulous benefits too! > > > > > >=================================== > > >This list is hosted by DevelopMentorR > > http://www.develop.com Some .NET > > >courses you may be interested in: > > > > > >Essential .NET: building applications and components with C# > > November 29 - > > >December 3, in Los Angeles http://www.develop.com/courses/edotnet > > > > > >View archives and manage your subscription(s) at > > http://discuss.develop.com > > > > > >=================================== > > >This list is hosted by DevelopMentorR http://www.develop.com > > >Some .NET courses you may be interested in: > > > > > >Essential .NET: building applications and components with C# > > >November 29 - December 3, in Los Angeles > > >http://www.develop.com/courses/edotnet > > > > > >View archives and manage your subscription(s) at > > http://discuss.develop.com > > > > _________________________________________________________________ > > Instant personal loans. Celebrate this season with your family. > > http://acm.bridgeovertw.com/hdfc/pl/landingpage/sep04/index.ht > > m?sitecode=611|395 > > Apply. > > > > =================================== > > This list is hosted by DevelopMentorR http://www.develop.com > > Some .NET courses you may be interested in: > > > > Essential .NET: building applications and components with C# > > November 29 - December 3, in Los Angeles > > http://www.develop.com/courses/edotnet > > > > View archives and manage your subscription(s) at > > http://discuss.develop.com > > > > =================================== > This list is hosted by DevelopMentor� http://www.develop.com > Some .NET courses you may be interested in: > > Essential .NET: building applications and components with C# > November 29 - December 3, in Los Angeles > http://www.develop.com/courses/edotnet > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with C# November 29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com
