473,569 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with PropertyGrid and string based Collection

I created a collection derived from CollectionBase that is just made up of
strings, called "StringList ". I have another object that has as a member
one of these StringList.

If I assign that object to a PropertyGrid, click on the collection editor
"..." and try to add a new string, I get an error message "Constructo r on
type System.String not found.".

Any ideas what I'm missing? If it can't create a new object of one of the
built-in base types something is wrong.

Thanks,
Terry

Here's my "StringList " class for reference

using System;

using System.Collecti ons;

namespace TestStringListA dd

{

/// <summary>

///

/// </summary>

public class StringList : CollectionBase

{

public StringList()

: base()

{

}

public void Add( String str )

{

this.List.Add( str );

}

public void Remove( String str )

{

this.List.Remov e( str);

}

public string this[ int index ]

{

get

{

return (String)this.Li st[index];

}

}

}

}
Nov 15 '05 #1
1 6435
I'll follow up on my own post with some additional information.

I discovered that "String" does not have a default constructor. Neither do
a number of other Framework classes, e.g. "IPEndPoint ". So, if I were to
make a collection class of "IPEndPoint " derived from CollectionBase I run
into the same problem.

So, I guess the real question is how to handle these classes that don't have
default constructors so PropertyGrid can construct new instances of them?

Thanks!
Terry
"Terry" <ch**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I created a collection derived from CollectionBase that is just made up of
strings, called "StringList ". I have another object that has as a member
one of these StringList.

If I assign that object to a PropertyGrid, click on the collection editor
"..." and try to add a new string, I get an error message "Constructo r on
type System.String not found.".

Any ideas what I'm missing? If it can't create a new object of one of the
built-in base types something is wrong.

Thanks,
Terry

Here's my "StringList " class for reference

using System;

using System.Collecti ons;

namespace TestStringListA dd

{

/// <summary>

///

/// </summary>

public class StringList : CollectionBase

{

public StringList()

: base()

{

}

public void Add( String str )

{

this.List.Add( str );

}

public void Remove( String str )

{

this.List.Remov e( str);

}

public string this[ int index ]

{

get

{

return (String)this.Li st[index];

}

}

}

}

Nov 15 '05 #2

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

Similar topics

3
6039
by: Dave Girvitz | last post by:
I have a PropertyGrid (Windows Forms App) based component that uses TypeConverters to generate ranges of acceptable values for properties. The idea was that I could download the key/value pairs from a database and manipulate the TypeConverters dynamically. The property grid then displays the property with a drop down list. It does work...
2
3964
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only one category(Appearance, Behavior,ecc.) but I want to chose directly which properties to show.I've read that I can use the SelectedObjects to put an...
2
6745
by: Eric Eggermann | last post by:
Hello, I'm using a PropertyGrid on my form in lieu of a big ugly dialog box, or rather several large dialogs, so the user can manipulate some objects. I've got a font field that displays with a nice little drop down feature showing the font properties slightly indented from the other properties. In the .Net editor, this works for quite a few...
0
1762
by: Steve Teeples | last post by:
I have a string collection within a class StringCollection scoll = new StringCollection(); public TestCaseProperties() { FunctionalitySupported(); scoll.Add("Apple"); scoll.Add("Banana"); }
1
11860
by: ANDRES BECERRA | last post by:
Herfried K. Wagner was kind enough to point me to the PropertyGrid control http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformspropertygridclasstopic.asp I have found a few samples of how to use the PropertyGrid control and have gained a decent understanding of it. But of course, as it usually the case, my needs go far...
12
1696
by: Ron M. Newman | last post by:
Hi, I can load an assembly using the Assembly.Load(....) However, I'd like dynamic loading of assemblies to be identical to putting an assembly reference in your VS2005 project. and yes, I know about the unloading problems. Let's say I don't care for the moment. If I have an assemlbly file at "c:\\assembly.dll" - how do I load it at...
3
1944
by: Brannon | last post by:
So when you use VS's View Designer, each object included is keyed off its Name. You cannot make the name the same as some other component. You can change the name in a PropertyGrid. I want to do a similar thing. I have a class (MissionManager with a bunch of static functions) that contains a static KeyedCollection<Missionof my objects. Each...
4
5439
by: Rohan | last post by:
I need to use the Collection editor of the propertyGrid, but i can't this to work, i looked around on the NET on collection and I am kinda lost. i have this so far, i don't know what i should do next Thank you Public class frmColor Dim xColors As New myColors
0
1671
by: michelqa | last post by:
I'm looking for a way to display a string collection where each element of the collection have some properties. By example : MyCollectionItem0 MyPropertyA MyPropertyB MCollectionItem1 MyPropertyA MyPropertyB For some reasons after reading a lot about PropertyGrid a take a look
0
7703
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...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
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...
0
6287
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...
0
5223
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
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
0
946
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...

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.