473,385 Members | 1,934 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,385 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 1834
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...
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...
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: 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...
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...

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.