473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Generics collection<T> bindinglist<T>

Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.

Or maybe someone has an easier way

Many Thanks

Mike
May 4 '06 #1
5 7573
"Mike Surcouf" <mike@$surcouf.co(.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.


I think you can use the Collection<T> constructor that takes an IList<T>
parameter, i.e.
gridRows = new BindingList<SalesInvoiceListCompassSelectRow>(rows );

Chris Jobson
May 4 '06 #2
"Mike Surcouf" <mike@$surcouf.co(.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.


I think you can use the Collection<T> constructor that takes an IList<T>
parameter, i.e.
gridRows = new BindingList<SalesInvoiceListCompassSelectRow>(rows );

Chris Jobson
May 4 '06 #3
"Mike Surcouf" <mike@$surcouf.co(.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.


I think you can use the Collection<T> constructor that takes an IList<T>
parameter, i.e.
gridRows = new BindingList<SalesInvoiceListCompassSelectRow>(rows );

Chris Jobson
May 4 '06 #4
"Mike Surcouf" <mike@$surcouf.co(.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.


I think you can use the Collection<T> constructor that takes an IList<T>
parameter, i.e.
gridRows = new BindingList<SalesInvoiceListCompassSelectRow>(rows );

Chris Jobson
May 4 '06 #5
Hi Chris

That worked perfectly thanks a lot.

Mike

"Chris Jobson" <ch**********@btinternet.com> wrote in message
news:ub*************@TK2MSFTNGP04.phx.gbl...
"Mike Surcouf" <mike@$surcouf.co(.uk> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a stored procedure wrapper that returns Collection<T>.
The wrapper is generated by codesmith so I don't really want to start
altering it.
I need to use this collection in a datagridview.
I would like the ability to add to this collection or delete from this
collection using the grid.
I know I will need to use Bindinglist<T> for this but I don't seem to be
able to cast from
collection<T> to bindinglist<T>

Sample Code

gridRows = (BindingList<SalesInvoiceListCompassSelectRow>)row s;

Error I get is

Unable to cast object of type
'System.Collections.ObjectModel.Collection`1[CompassEdi.SalesInvoiceListCompassSelectRow]'
to type
'System.ComponentModel.BindingList`1[CompassEdi.SalesInvoiceListCompassSelectRow]'.

Maybe I have to iterate through Collection<T> and add to BindingList<T>.


I think you can use the Collection<T> constructor that takes an IList<T>
parameter, i.e.
gridRows = new BindingList<SalesInvoiceListCompassSelectRow>(rows );

Chris Jobson

May 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
2
by: ESPNSTI | last post by:
Hi, I'm trying to use a generics dictionary with a key class that implements and needs IComparable<>. However when I attempt to use the dictionary, it doesn't appear to use the IComparable<> to...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
1
by: Michael Primeaux | last post by:
Why does the generic SortedList and generic SortedDictionary not define any virtual members? Thanks, Michael
4
by: Michel Walsh | last post by:
Hi, A datagrid has its DataSource set to a BindingList<CustomClass>. While the ListChanged event fires AFTER a deletion, I am looking for a simple way to be notified BEFORE the item would be...
7
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list...
5
by: David Longnecker | last post by:
I'm working to create a base framework for our organization for web and client-side applications. The framework interfaces with several of our systems and provides the business and data layer...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
2
by: Oleg Subachev | last post by:
What is the difference between Collection<Tand List<T? Both of them implement the same set of interfaces. Oleg Subachev
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.