array of objects in a User Control

  • Thread starter Thread starter Vincent Finn
  • Start date Start date
V

Vincent Finn

Hi,

I am writing a Control (in C#) and I want to give the user access to
an array of items in it.
If I make a property that returns the array it doesn't work properly
in the designer.

The control properties in design mode show my propery
I can select it
that brings up a window that allows me to add new items and set their
properties
This seems to work and the new items are displayed
As soon as I compile they vanish.

The array created in the property editor seems to be loaded into
memory but not saved in the .cs file

I can use the property fine in my code it is just in the property
window I can't.

Here is the definitions I am using, nothing special about them

Anyone any idea what I am doing wrong?

Vin

/////////////////////////////////////////////////////////

// in the Control
private Test[] m_aTests;
public Test[] Tests
{
get
{
return m_aTests;
}
set
{
m_aTests = value;
}
}

// the class Test
public class Test
{
private int m_i;
public Test()
{
}
public int i
{
get
{
return m_i;
}
set
{
m_i = value;
}
}
}
 
I dont' think the designer can serialize it to the array very well, because
it would have to constantly be changing its size. I have done this with
stringcollections, and that works well.
 
I dont' think the designer can serialize it to the array very well, because
it would have to constantly be changing its size. I have done this with
stringcollections, and that works well.

I have seen 3rd party controls handle it
but looking at them agani I think they may be using custom editors
rather than a simple built in one the way I thought they were

So maybe I was just assuming it was easier than it is

Will have to look into the custom editors

Thanks

Vin
 
Back
Top