473,403 Members | 2,359 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,403 software developers and data experts.

CollectionBase & DataGrid --- Please help!!

I have subclassed CollectionBase. I have also implemented GetEnumerator().
I have tried to set the DataSource of a DataGrid to an instance of my
subclass. However, the items in the grid are not obtained via the Enumerator
that I create in the GetEnumerator() method.
I have tried elplicitly implementing IEnumerable on my sublass as well.
Can anyone help on this? Thanks in advance.
Jul 21 '05 #1
5 3499
Steve,
CollectionBase already implements IEnumerator & the GetEnumerator method.

What you are really doing, that the base version is not working, Can you
post some code?

Hope this helps
Jay

"Steve M" <st***@nospam.com> wrote in message
news:Wx****************@twister.rdc-kc.rr.com...
I have subclassed CollectionBase. I have also implemented GetEnumerator().
I have tried to set the DataSource of a DataGrid to an instance of my
subclass. However, the items in the grid are not obtained via the Enumerator that I create in the GetEnumerator() method.
I have tried elplicitly implementing IEnumerable on my sublass as well.
Can anyone help on this? Thanks in advance.

Jul 21 '05 #2
> CollectionBase already implements IEnumerator & the GetEnumerator method.

What you are really doing, that the base version is not working, Can you
post some code?


Jay,

CollectionBase implements IEnumerable.

In my subclass I have created my own new GetEnumerator() method (oddly
enough, MS decided not to make that method virtual).

If I set the DataSource of a DataGrid to be an instance of my new subclass,
it does not work properly.

I can, however, get it to work properly in a DataGrid if I explicitly
implement IList in my subclass -- even though CollectionBase already
implements it. When I do this, the DataGrid properly fills all my items.
(Although I still never see my GetEnumerator() method called--but at least
the DataGrid now works.)

Thanks.
Jul 21 '05 #3
Steve,
CollectionBase implements IEnumerable. Doh! I knew that I typed the wrong one :-(
In my subclass I have created my own new GetEnumerator() method (oddly
enough, MS decided not to make that method virtual). Why have you created a new one???

CollectionBase encapsulates an ArrayList, CollectionBase.GetEnumerator
returns this ArrayList's Enumerator.

Classes that derive from CollectionBase operate on this ArrayList via the
protected List or InnerList properties. CollectionBase.List causes the
protected virtual CollectionBase.On* methods to be called, while
CollectionBase.InnerList allows direct access to the ArrayList itself,
without calling the CollectionBase.On* methods.

Not being virtual seems to be the correct design decision for the class!

So I have to ask:

Why are you creating your own GetEnumerator method?
Can you post code on what you are really doing?
I can, however, get it to work properly in a DataGrid if I explicitly
implement IList in my subclass -- even though CollectionBase already
implements it. When I do this, the DataGrid properly fills all my items.
(Although I still never see my GetEnumerator() method called--but at least
the DataGrid now works.) Correct! CollectionBase implements IList and directs every thing to its
encapsulated ArrayList. However you may have created a new GetEnumerator in
your class, CollectionBase, hence its IList implementation will not know
about it.

So again:
Why are you creating your own GetEnumerator method?
Can you post code on what you are really doing?

Hope this helps
Jay

"Steve M" <st***@nospam.com> wrote in message
news:hu*******************@twister.rdc-kc.rr.com...
CollectionBase already implements IEnumerator & the GetEnumerator method.
What you are really doing, that the base version is not working, Can you
post some code?


Jay,

CollectionBase implements IEnumerable.

In my subclass I have created my own new GetEnumerator() method (oddly
enough, MS decided not to make that method virtual).

If I set the DataSource of a DataGrid to be an instance of my new

subclass, it does not work properly.

I can, however, get it to work properly in a DataGrid if I explicitly
implement IList in my subclass -- even though CollectionBase already
implements it. When I do this, the DataGrid properly fills all my items.
(Although I still never see my GetEnumerator() method called--but at least
the DataGrid now works.)

Thanks.

Jul 21 '05 #4
Well, I don't want to post my code.
I got it working -- though since I can't see the source code for DataGrid, I
don't know why it behaves the way it does.
I created my own GetEnumerator() because my CollectionBase subclass requires
its own special enumerator -- it's just the way the clas works.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Steve,
CollectionBase implements IEnumerable. Doh! I knew that I typed the wrong one :-(
In my subclass I have created my own new GetEnumerator() method (oddly
enough, MS decided not to make that method virtual).

Why have you created a new one???

CollectionBase encapsulates an ArrayList, CollectionBase.GetEnumerator
returns this ArrayList's Enumerator.

Classes that derive from CollectionBase operate on this ArrayList via the
protected List or InnerList properties. CollectionBase.List causes the
protected virtual CollectionBase.On* methods to be called, while
CollectionBase.InnerList allows direct access to the ArrayList itself,
without calling the CollectionBase.On* methods.

Not being virtual seems to be the correct design decision for the class!

So I have to ask:

Why are you creating your own GetEnumerator method?
Can you post code on what you are really doing?
I can, however, get it to work properly in a DataGrid if I explicitly
implement IList in my subclass -- even though CollectionBase already
implements it. When I do this, the DataGrid properly fills all my items.
(Although I still never see my GetEnumerator() method called--but at least
the DataGrid now works.)

Correct! CollectionBase implements IList and directs every thing to its
encapsulated ArrayList. However you may have created a new GetEnumerator

in your class, CollectionBase, hence its IList implementation will not know
about it.

So again:
Why are you creating your own GetEnumerator method?
Can you post code on what you are really doing?

Hope this helps
Jay

"Steve M" <st***@nospam.com> wrote in message
news:hu*******************@twister.rdc-kc.rr.com... CollectionBase already implements IEnumerator & the GetEnumerator method.
What you are really doing, that the base version is not working, Can you post some code?


Jay,

CollectionBase implements IEnumerable.

In my subclass I have created my own new GetEnumerator() method (oddly
enough, MS decided not to make that method virtual).

If I set the DataSource of a DataGrid to be an instance of my new

subclass,
it does not work properly.

I can, however, get it to work properly in a DataGrid if I explicitly
implement IList in my subclass -- even though CollectionBase already
implements it. When I do this, the DataGrid properly fills all my items.
(Although I still never see my GetEnumerator() method called--but at least the DataGrid now works.)

Thanks.


Jul 21 '05 #5
Steve,
Well, I don't want to post my code. That's understandable.
I created my own GetEnumerator() because my CollectionBase subclass requires its own special enumerator -- it's just the way the clas works. If you need your own enumerator, then I would suggest you not use
CollectionBase as CollectionBase was not really designed to replace its
enumerator... I suspect you had to replace enough of CollectionBase, that it
will be cleaner to start a collection from scratch (a Class that implements
IList itself).

Hope this helps
Jay

"Steve M" <st***@nospam.com> wrote in message
news:CU*****************@twister.rdc-kc.rr.com... Well, I don't want to post my code.
I got it working -- though since I can't see the source code for DataGrid, I don't know why it behaves the way it does.
I created my own GetEnumerator() because my CollectionBase subclass requires its own special enumerator -- it's just the way the clas works.

<<snip>>
Jul 21 '05 #6

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

Similar topics

1
by: '[] WiRaN | last post by:
hi friends, I necessary a example of use checkbox in datagrid, help me?
1
by: ray well | last post by:
hi, i need to preview the keys in my app in order to process F1-F10. i set keypreview of my form to true, and it does capture the keystrokes from all over the forms controls which i then...
1
by: MDB | last post by:
Hello All, I have a datagrid with multiple rows and columns When a user taps a column I update the quantity by one and then when they tap and hold, I display a context menu with Subtract and...
1
by: Trevor Oakley | last post by:
I have been learning ASPNET from ASP.NET Kick Start (Stephen Walther), and I have hit a problem with adding a DropDownList onto a DataGrid. I have added some first results for searches at...
6
by: Erik H. | last post by:
Trying to connect to MySQL db on localhost, and populate datagrid from a dataset using code inline method. Getting the following compile error: Error Message: "CS0246: The type or namespace...
1
by: sg | last post by:
Hi I'm starting programming in visual studio and c# and i have a problem with filtering datagrid. I build form with datagrid and i see data from database. I find in microsoft web page...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
5
by: Steve M | last post by:
I have subclassed CollectionBase. I have also implemented GetEnumerator(). I have tried to set the DataSource of a DataGrid to an instance of my subclass. However, the items in the grid are not...
3
by: Motaz | last post by:
Hi All My name is Motaz; I am still learning C#.net and getting good at it day be day. I was just wondering if any one can help me with my new Web Application. I am having some small...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.