473,729 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store ArrayList as Settings Object

Hello,

I see quite a few questions, but no valid responses to the question...

How do I store an ArrayList of items in a Properties file via the GUI?

I am able to select the System.Collecti ons.ArrayList type, but I'm unable to
determine what to type into the Value feild for a default setting so the
property will not be null at runtime...

Thanks,
Mike
Sep 5 '06 #1
3 2348
Hi Mike,

When we add a setting in the Settings tab in a project's Project designer
and select System.Collecti ons.ArrayList as the type of the setting, we
could click the cell under the Value column in the same row and click the
button on the right to edit the items in the collection.

In the Object Collection Editor dialog, if we click Add button, a new item
of type System.Object is added to the collection. However, we couldn't
modify the value of the object, because the properties grid on the right
hand is grey. Click ok button and close the dialog. We could see an xml
text appears in the Value cell. The content of the xml text is like below.

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfAnyTy pe xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<anyType/>
</ArrayOfAnyType>

So we could only modify content in the <anyTypenode in the above xml text
to specify the default values of items in the ArryList setting. The
following is a sample.

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfAnyTy pe xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<anyType xsi:type="xsd:i nt">1</anyType>
<anyType xsi:type="xsd:s tring">2</anyType>
<anyType
xsi:type="xsd:d ateTime">2006-09-06T10:58:55.496 1857+08:00</anyType>
</ArrayOfAnyType>

Copy the new xml text back to the Value cell of the setting.

In the above sample, three items are added in the collection, among which
the first item is of type Int32 with the value of 1 and the second item is
of type String with the value of "2" and the third item is of type DateTime
with the value of "2006-09-06 10:58:55".

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 6 '06 #2
Ok.. I understand and have that working... now if I want the ArrayList to be
an ArrayList of a custom class I write...

Do I just mark the class Serializable and then select that type?

"Linda Liu [MSFT]" wrote:
Hi Mike,

When we add a setting in the Settings tab in a project's Project designer
and select System.Collecti ons.ArrayList as the type of the setting, we
could click the cell under the Value column in the same row and click the
button on the right to edit the items in the collection.

In the Object Collection Editor dialog, if we click Add button, a new item
of type System.Object is added to the collection. However, we couldn't
modify the value of the object, because the properties grid on the right
hand is grey. Click ok button and close the dialog. We could see an xml
text appears in the Value cell. The content of the xml text is like below.

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfAnyTy pe xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<anyType/>
</ArrayOfAnyType>

So we could only modify content in the <anyTypenode in the above xml text
to specify the default values of items in the ArryList setting. The
following is a sample.

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfAnyTy pe xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<anyType xsi:type="xsd:i nt">1</anyType>
<anyType xsi:type="xsd:s tring">2</anyType>
<anyType
xsi:type="xsd:d ateTime">2006-09-06T10:58:55.496 1857+08:00</anyType>
</ArrayOfAnyType>

Copy the new xml text back to the Value cell of the setting.

In the above sample, three items are added in the collection, among which
the first item is of type Int32 with the value of 1 and the second item is
of type String with the value of "2" and the third item is of type DateTime
with the value of "2006-09-06 10:58:55".

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 6 '06 #3
Hi Mike,

When we add a setting in the graphic designer and click the arrow button in
the Type column to select a type, we will see some simple type in the
drop-down list. If the required type does not appear in this list by
default, you can choose one by clicking the Browse list option to open the
Select a Type dialog.

The only items that appear in this list are .NET Framework types that can
be serialized, whether by TypeConverter(b y converting to and from a string)
or with the XMLSerializer.

The type System.Collecti ons.ArrayList uses XMLSerializer to serialize. So
an XML text appears in the value cell for a setting of type ArrayList. We
could modify the XML text to add elements of simple type, such as string,
integer, datetime, etc. However, if we want to add an element of a complex
type, e.g a custom type, it's not enough to set the custom type
Serializable. We may need to make a use of XMLSerializer to do this. I am
researching on how to do this now and will get it back to you ASAP.

On the other hand, you could also add a setting of your custom types,
although they'll need a TypeConverter just as the .NET Framework types do.

To do this, we should derive a new class from TypeConverter and apply it to
the custom type. For more information on how to implement TypeConverter,
you may refer to the link as follow.

http://msdn2.microsoft.com/en-us/library/ayybcxe5.aspx

Hope this helps.
Sincerely,
Linda Liu
Microsoft Online Community Support

Sep 8 '06 #4

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

Similar topics

3
7174
by: Tony Johansson | last post by:
Hello! Assume you want to store field object that a chess board consist of. A chess board consist of 64 fields where each field is either white or black. Now to my question how should I implement this putFieldAt below when I have field object that should be placed at position row i and kolumn j. So this putFieldAt is called 64 timmes where i has the value from 0 to 7 and j has value from 0 to
3
1714
by: Pablo Salazar | last post by:
Hi People Few day ago, somebody sent me this code. ArrayList al = new ArrayList(); //Insertar datos en la lista: al.Add("Ejemplo1"); al.Add("Ejemplo2"); It can store two string in ArrayList, my question is
11
3612
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a million lines. b) I need to store the contents into a unique hash. c) I need to then sort the data on a specific field. d) I need to pull out certain fields and report them to the user.
3
1945
by: Bob | last post by:
I am a new java convert to asp.net. I'm trying to create an web application that will allow users to change their custom settings easily. Is there a class in .net that is similar to java's Property class that can deal with user's custom settings?
10
1769
by: Craig Lister | last post by:
I'm a newbie.. I'm trying to list all files in a directory, and store them in a aFile object. As I iterate through each file, I store the size, name, path, date etc... How do I store them once the object is created? I thought they would simply be added to an ArrayList, but this doesn't seem to be working. eg:
4
8728
by: eugenet | last post by:
Hello, I am writing a Windows Forms application using .NET Framework 2.0 and Visual Studio 2005. I would like to use Properties.Settings class to persist a collection of custom objects. For that I am creating a setting called Connections of type System.Collections.ArrayList using the Properties designer in VS.
10
4265
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version. Because of this, I am unable to store these settings in the App.Config file, as this gets updated every time the application does, and there doesn't appear to be a way of preventing this. Most of my application settings are kept in the...
3
4104
by: ricardo.sobral.santos | last post by:
Hi there, I cannot store an arraylist in a session. I have read some posts and still found no solution. I am sure it might be something simple, but since I have been around it for quite sometime I ask for your advice. Here is my page load. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
1
1350
by: Armin Zingler | last post by:
Hi, I add event handlers to different events of objects of different type. In an array or arraylist, I want to store the information about which events I added. Later, I want to process the arraylist and detach all the event handlers. My problem is that I don't know which information to store. When removing the handlers in a loop, the most important thing is that I don't want to distinguish between the different object types and events,...
0
8921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9284
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.