Advertisement

03.28.2008 at 05:21AM PDT, ID: 23276899
[x]
Attachment Details

How to pass a Generic custom collection?

Asked by SniperX1 in .NET Framework 2.0, Microsoft Visual Basic.Net, Visual Studio .NET 2005

Tags: VB.Net

Hello, I am trying to pass a generic custom collection "Public Class xList(of T) Inherits BindingList(of T)" to a form which will display the contents of the collection in a datagridview. As i do not know at design time what the type is within the collection, then the form that is going to display the data is going to have to find out what type is in the collection when is initializes.

The problem i am having is passing the generic collection to the form.

' The custom collection
Public Class xList(of T) Inherits BindingList(of T)
...
End Class

' The form to display objects, this is where the problem is, it will not accept (of T)
Public Class form1
Public sub New (ByVal x as xList(of T))
'code to find type
...
End Sub
End Class

'Code passing the collection, contained in another form
Public sub passx(A as TypeA)
dim x as xList(of TypeA) = new xList(of TypeA)
x.Add(A)
dim frm as form1 = new form1(x)
frm.showdialog
...
End sub

hopefully this makes sense to someone.

Thanks to all in advance.

AndyStart Free Trial
[+][-]03.28.2008 at 06:58AM PDT, ID: 21230403

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 09:06AM PDT, ID: 21231634

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Microsoft Visual Basic.Net, Visual Studio .NET 2005
Tags: VB.Net
Sign Up Now!
Solution Provided By: VBRocks
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628