473,323 Members | 1,537 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,323 software developers and data experts.

array of objects in a User Control

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;
}
}
}

Jul 21 '05 #1
2 1832
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.

"Vincent Finn" <1@2.com> wrote in message
news:36********************************@4ax.com...
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;
}
}
}

Jul 21 '05 #2
On Fri, 29 Oct 2004 14:59:57 -0400, "Marina" <so*****@nospam.com>
wrote:
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
Jul 21 '05 #3

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

Similar topics

38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
5
by: tony collier | last post by:
This is an array question but it is based in my web page so i shall give scenario: when the client navigates to the page, the page takes some figures and does loads of calulations in page_load...
0
by: Vincent Finn | last post by:
Hi, I have a user control and I want an array of items to be available to the user In my case these items are a class called Needle. I added a property called Needles to get\set the array...
2
by: Vincent Finn | last post by:
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...
4
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
9
by: IamIan | last post by:
I'm using an array to store map features (name, lat, lon, caption, etc), from which the user can then select an individual feature. The problem is that when thousands of features are stored in the...
5
by: Stephen3776 | last post by:
I am doing an inventory control progam and trying to output a multiple array, I am getting an illegal conversion error java.lang.double !d. Can somebody tell me what I am doing wrong or if there is...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
1
by: eihabisaac | last post by:
hey i need to create an array of objects then to use it in a list control,, - im asking the user to enter data using textboxes and combo box in a dialog then he click ok ... -after the ok i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.