Click here to Skip to main content
15,900,455 members
Home / Discussions / C#
   

C#

 
GeneralRe: Professional Pin
Ennis Ray Lynch, Jr.10-Jan-07 13:33
Ennis Ray Lynch, Jr.10-Jan-07 13:33 
GeneralRe: Professional Pin
led mike11-Jan-07 4:45
led mike11-Jan-07 4:45 
AnswerRe: Books on OOPS and C# Pin
Christian Graus9-Jan-07 10:13
protectorChristian Graus9-Jan-07 10:13 
AnswerRe: Books on OOPS and C# Pin
KevinMac9-Jan-07 17:01
KevinMac9-Jan-07 17:01 
GeneralRe: Books on OOPS and C# Pin
Blumen10-Jan-07 5:23
Blumen10-Jan-07 5:23 
GeneralRe: Books on OOPS and C# Pin
KevinMac10-Jan-07 6:12
KevinMac10-Jan-07 6:12 
GeneralRe: Books on OOPS and C# Pin
Blumen11-Jan-07 6:20
Blumen11-Jan-07 6:20 
QuestionCollectionEditor problem Pin
Barguast29-Jan-07 8:21
Barguast29-Jan-07 8:21 
I've been working on a CollectionEditor, but I'm getting an obscure error message whenever I try to use the Add button. To reproduce and demonstrate this error, I've made this short piece of code:

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Collections.ObjectModel;<br />
using System.ComponentModel.Design;<br />
using System.ComponentModel;<br />
using System.Drawing.Design;<br />
<br />
namespace Test<br />
{<br />
    public abstract class BaseItem<br />
    {<br />
        private string _name;<br />
<br />
        public string Name<br />
        {<br />
            get { return this._name; }<br />
            set { this._name = value; }<br />
        }<br />
    }<br />
<br />
    public class IntItem : BaseItem<br />
    {<br />
        private int _value;<br />
<br />
        public int Value<br />
        {<br />
            get { return this._value; }<br />
            set { this._value = value; }<br />
        }<br />
    }<br />
<br />
    public class StringItem : BaseItem<br />
    {<br />
        private string _value;<br />
<br />
        public string Value<br />
        {<br />
            get { return this._value; }<br />
            set { this._value = value; }<br />
        }<br />
    }<br />
<br />
    public class ItemCollection : Collection<BaseItem><br />
    {<br />
    }<br />
<br />
    public class ItemCollectionEditor : CollectionEditor<br />
    {<br />
        public ItemCollectionEditor(Type type)<br />
            : base(type)<br />
        {<br />
        }<br />
<br />
        protected override Type[] CreateNewItemTypes()<br />
        {<br />
            return new Type[] { typeof(IntItem), typeof(StringItem) };<br />
        }<br />
    }<br />
<br />
    public class ItemCollectionHostControl : System.Windows.Forms.Control<br />
    {<br />
        private ItemCollection _items;<br />
<br />
        public ItemCollectionHostControl()<br />
        {<br />
            this._items = new ItemCollection();<br />
        }<br />
<br />
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),<br />
         Editor(typeof(ItemCollectionEditor), typeof(UITypeEditor))]<br />
        public ItemCollection Items<br />
        {<br />
            get { return this._items; }<br />
        }<br />
    }<br />
}


This creates a control called ItemCollectionHostControl, which has a 'Items' property. In this, you can add two types - 'IntItem' and 'StringItem'. It doesn't happen all of the time, but sometimes I get the following error message:

"The value 'Test.IntItem' is not of type 'Test.BaseItem' and cannot be used in this generic collection"

You may be able to add some items initially, but try then compiling the project, and adding some more.

Can someone see why this error is occurring, or what I'm doing wrong? If someone could try the code and see if it happens with them, that'd be great too.

Thanks
GeneralRe: CollectionEditor problem Pin
Barguast29-Jan-07 23:22
Barguast29-Jan-07 23:22 
QuestionTimeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 7:44
btsrinath9-Jan-07 7:44 
AnswerRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Dave Kreskowiak9-Jan-07 7:55
mveDave Kreskowiak9-Jan-07 7:55 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 8:55
btsrinath9-Jan-07 8:55 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Dave Kreskowiak9-Jan-07 8:59
mveDave Kreskowiak9-Jan-07 8:59 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 9:37
btsrinath9-Jan-07 9:37 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Dave Kreskowiak9-Jan-07 9:43
mveDave Kreskowiak9-Jan-07 9:43 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 9:55
btsrinath9-Jan-07 9:55 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath10-Jan-07 5:31
btsrinath10-Jan-07 5:31 
AnswerRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Luc Pattyn9-Jan-07 9:50
sitebuilderLuc Pattyn9-Jan-07 9:50 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 10:25
btsrinath9-Jan-07 10:25 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
Luc Pattyn9-Jan-07 10:50
sitebuilderLuc Pattyn9-Jan-07 10:50 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Pin
btsrinath9-Jan-07 11:41
btsrinath9-Jan-07 11:41 
GeneralRe: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. [modified] Pin
Luc Pattyn9-Jan-07 11:54
sitebuilderLuc Pattyn9-Jan-07 11:54 
QuestionDetermining time of query end Pin
sopho249-Jan-07 7:07
sopho249-Jan-07 7:07 
AnswerRe: Determining time of query end Pin
btsrinath9-Jan-07 12:00
btsrinath9-Jan-07 12:00 
Questionwriting in a file Pin
netJP12L9-Jan-07 6:12
netJP12L9-Jan-07 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.