473,387 Members | 3,684 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.

CollectionBase derived class not saving design time items

hi
On a form ive added my custom component (MyComponent) which has a property
(IDs in the expample code) exposing a collection of int16. I see this
property in the PropertyGrid and I dont have trouble adding items to the
collection at design time (using standard CollectionEditor class). I can
Add, remove items at design time, however all the items are lost after a
compilation.

public class MyComponent : Component{
Int16Collection int_col;

public Int16Collection IDs{
get{
return int_col;
}
set{
int_col = value;
}
}
}

Here's my custom collection class.

public class Int16Collection : CollectionBase {
public Int16 this[ int index ]{
get{
return( (Int16) List[index] );
}
set{
List[index] = value;
}
}
.....
....

I dont understand how/why all the items added at design time disappear on
compilation of the form. Where are the items saved between design time and
compilation time?

any help much appreciated

Nov 17 '05 #1
3 1528
Add the following to your IDs property
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]

/claes
"niyad" <ms*@iris.co.uk> wrote in message
news:c0**********@sparta.btinternet.com...
hi
On a form ive added my custom component (MyComponent) which has a property
(IDs in the expample code) exposing a collection of int16. I see this
property in the PropertyGrid and I dont have trouble adding items to the
collection at design time (using standard CollectionEditor class). I can
Add, remove items at design time, however all the items are lost after a
compilation.

public class MyComponent : Component{
Int16Collection int_col;

public Int16Collection IDs{
get{
return int_col;
}
set{
int_col = value;
}
}
}

Here's my custom collection class.

public class Int16Collection : CollectionBase {
public Int16 this[ int index ]{
get{
return( (Int16) List[index] );
}
set{
List[index] = value;
}
}
....
...

I dont understand how/why all the items added at design time disappear on
compilation of the form. Where are the items saved between design time and
compilation time?

any help much appreciated

Nov 17 '05 #2
Still the same. I had tried that before.

"Claes Bergefall" <cl********************@frontec.se> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Add the following to your IDs property
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]

/claes
"niyad" <ms*@iris.co.uk> wrote in message
news:c0**********@sparta.btinternet.com...
hi
On a form ive added my custom component (MyComponent) which has a property (IDs in the expample code) exposing a collection of int16. I see this
property in the PropertyGrid and I dont have trouble adding items to the
collection at design time (using standard CollectionEditor class). I can
Add, remove items at design time, however all the items are lost after a
compilation.

public class MyComponent : Component{
Int16Collection int_col;

public Int16Collection IDs{
get{
return int_col;
}
set{
int_col = value;
}
}
}

Here's my custom collection class.

public class Int16Collection : CollectionBase {
public Int16 this[ int index ]{
get{
return( (Int16) List[index] );
}
set{
List[index] = value;
}
}
....
...

I dont understand how/why all the items added at design time disappear on compilation of the form. Where are the items saved between design time and compilation time?

any help much appreciated


Nov 17 '05 #3
Hmm, that should work
I noticed that IDs property is Read/Write, Perhaps that's
the reason the attribute doesn't work in your case.

/claes
"niyad" <ms*@iris.co.uk> wrote in message
news:c0**********@titan.btinternet.com...
Still the same. I had tried that before.

"Claes Bergefall" <cl********************@frontec.se> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Add the following to your IDs property
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]

/claes
"niyad" <ms*@iris.co.uk> wrote in message
news:c0**********@sparta.btinternet.com...
hi
On a form ive added my custom component (MyComponent) which has a

property (IDs in the expample code) exposing a collection of int16. I see this
property in the PropertyGrid and I dont have trouble adding items to the collection at design time (using standard CollectionEditor class). I can Add, remove items at design time, however all the items are lost after a compilation.

public class MyComponent : Component{
Int16Collection int_col;

public Int16Collection IDs{
get{
return int_col;
}
set{
int_col = value;
}
}
}

Here's my custom collection class.

public class Int16Collection : CollectionBase {
public Int16 this[ int index ]{
get{
return( (Int16) List[index] );
}
set{
List[index] = value;
}
}
....
...

I dont understand how/why all the items added at design time disappear on compilation of the form. Where are the items saved between design time and compilation time?

any help much appreciated



Nov 17 '05 #4

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

Similar topics

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...
1
by: m. pollack | last post by:
Hi all, I'm still trying to get to the bottom of the problem I am having with the CollectionBase class and the Object Collection Editor. Briefly put, I am exposing a strongly-typed collection...
0
by: rein.petersen | last post by:
Hi All, Some of you may have encountered complications when trying to serialize an object derived from CollectionBase (implementing ICollection or IEnumerable). Specifically, the...
1
by: Mike Pollett | last post by:
Hi, I have used the ISerializable interface before and the code below worked fine. Until I derived it from CollectionBase. The code will still serialize and deserialize the properties in this class...
5
by: Eric Johannsen | last post by:
I have a simple object that inherits from CollectionBase and overrides the Count property: namespace MyTest { public class CollTest : System.Collections.CollectionBase { public override int...
3
by: niyad | last post by:
hi On a form ive added my custom component (MyComponent) which has a property (IDs in the expample code) exposing a collection of int16. I see this property in the PropertyGrid and I dont have...
6
by: DelGator | last post by:
Foundation...Accessing derived class members through a variable of their base class is just a matter of casting the variable to the derived class. How would you access the derived class members...
4
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits...
2
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count,...
0
by: Marcus Müller | last post by:
Hi, I'm using classes with the ExpandableObjectConverter attibute in a UserControl for properties. This works fine for some classes, and properties of these classes can be edited during design...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.