473,802 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Properties window - accessing collections

I have created a user control that includes the following field:
[Browsable(true)]
protected TreeColumn[] columns = new TreeColumn[3];

This is accessed via an accessor as follows:
pubilc TreeColumn[] Columns
{
get { return columns; }
set { columns = value; }
}

Now, at design time, I can see the "Columns" property in the property editor
and I can expand it to show three items. However, I want to be able to
change the values of these three columns, but VS has made them read only, so
will not let me make any changes.

Any suggestions as to how I get access to the public properties of the
TreeColum class?

On a second point, I get a button I can click that opens the collection
editor. This gives me add and remove buttons that are not helpful. I need my
array fixed at 3 items. Pressing the add button causes an error message -
can I either suppress the collection editor or can I remove these buttons?

Thanks
Steve
Mar 23 '06 #1
6 3436
Hi.
Use class inherited from ExpandableObjec tConverter and its CanConvertTo and
CanConvertFrom methods for editing or displaying the items of your array. You
can find detailed info in MSDN.
The second question is still opened even for me. I do not know how to
disable/suppress collection editor button in the property grid too. Does
anybody know?
Thanks.
Apr 12 '06 #2
You will have to write a custom editor for you're spefic attributes and
specy that UIEditor in the attributes of the item. This will then display
you're own editor -- without using the default Collections editor -- hence
no button.

Jamie
"Brko" <Br**@discussio ns.microsoft.co m> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hi.
Use class inherited from ExpandableObjec tConverter and its CanConvertTo
and
CanConvertFrom methods for editing or displaying the items of your array.
You
can find detailed info in MSDN.
The second question is still opened even for me. I do not know how to
disable/suppress collection editor button in the property grid too. Does
anybody know?
Thanks.

Apr 12 '06 #3
Hi. Thanks. I found this solution too. But when I created my own UIEditor it
didn't work for the property of the List<MyClass> type. May be List<> generic
defines its own CollectionEdito r. I tryied to create my own editor for other
types and it worked. Does anybody know how to change UIEditor for the List<>
generic?
Thanks once more time.
B.
Apr 13 '06 #4
Here's s simple one I use -- this works OK, the dialog tha tthis code is
showing is just a simple 2 column datagrid view with key value pairs -- it
seems similar to what you are trying to do.

class CostEditor : UITypeEditor
{
private IWindowsFormsEd itorService editorService = null;

public override UITypeEditorEdi tStyle
GetEditStyle(Sy stem.ComponentM odel.ITypeDescr iptorContext context)
{
return UITypeEditorEdi tStyle.Modal;
}

public override object EditValue(
ITypeDescriptor Context context,
IServiceProvide r provider,
object value)
{
if (provider != null)
{
editorService =
provider.GetSer vice(
typeof(IWindows FormsEditorServ ice))
as IWindowsFormsEd itorService;
}

if (editorService != null)
{
Prices frm = new Prices((Diction ary<string, decimal>)value) ;
frm.ShowDialog( );
if (frm.DialogResu lt == DialogResult.OK ) return value;
}

return null;

}

Then where you define the Property you need the following

[Description("Th is indicate whether this is a menu that is
called on start of a POS device."),
Category("Price s"),
Editor(typeof(C ostEditor), typeof(UITypeEd itor))]
/// <Summary>
/// Returns the prices for all plans that apply to this item
/// </Summary>
public Dictionary<stri ng, decimal> Prices
{
get { return _Prices; }
}

This way still presents the button to display the editor, but it displays my
grid not the default collection editor. My DataGridView is disabled for
editing, but if you allow editing and define the set in the property, and
also define the attribute [ReadOnly(False)] this will allow you to edit
you're values in you;re own dialog.

Hope this helps

Jamie
"Brko" <Br**@discussio ns.microsoft.co m> wrote in message
news:B6******** *************** ***********@mic rosoft.com...
Hi. Thanks. I found this solution too. But when I created my own UIEditor
it
didn't work for the property of the List<MyClass> type. May be List<>
generic
defines its own CollectionEdito r. I tryied to create my own editor for
other
types and it worked. Does anybody know how to change UIEditor for the
List<>
generic?
Thanks once more time.
B.

Apr 13 '06 #5
Now you opened my eyes. The problem of my code is that, I didn't inherit my
editor class directly from UITypeEditor but from CollectionEdito r class which
is ancestor of UITypeEditor. I just wanted to suppress displaying the edit
button in the PropertyGrid for some conditions. But it seem to be impossible
to inherit correctly the new class from the CollectionEdito r class. When I
put the breakpoint into the constructor of the class inherited of
CollectionEdito r the programm doesn't stop there. Probably my editor is not
created even I specified the EditorAttribute correctly for my property.

This is non-properly working code:
public class iSTConfigVar
{
public string name = string.Empty;
public string value = string.Empty;
}

public class BLVarsEditor : CollectionEdito r
{
public BLVarsEditor()
: base(typeof(Lis t<iSTConfigVar> ))
{
}

public override UITypeEditorEdi tStyle GetEditStyle(IT ypeDescriptorCo ntext
context)
{
return UITypeEditorEdi tStyle.None;
//return base.GetEditSty le(context);
}
}

private List<iSTConfigV ar> tralala = new List<iSTConfigV ar>();

[EditorAttribute (typeof(BLVarsE ditor), typeof(Collecti onEditor))]
public List<iSTConfigV ar> TestListGeneric Value
{
get
{
return tralala;
}
set
{
tralala = value;
}
}
This is working code:
public class iSTConfigVar
{
public string name = string.Empty;
public string value = string.Empty;
}

public class BLVarsEditor : UITypeEditor
{
public BLVarsEditor()
{
}

public override UITypeEditorEdi tStyle GetEditStyle(IT ypeDescriptorCo ntext
context)
{
return UITypeEditorEdi tStyle.None;
//return base.GetEditSty le(context);
}
}

private List<iSTConfigV ar> tralala = new List<iSTConfigV ar>();

[EditorAttribute (typeof(BLVarsE ditor), typeof(UITypeEd itor))]
public List<iSTConfigV ar> TestListGeneric Value
{
get
{
return tralala;
}
set
{
tralala = value;
}
}

The only difference is, the first editor is inherited directly from
UITypeEditor and the second is inherited from CollectionEdito r.

Thanks for any help.
B.
Apr 13 '06 #6
I forgot to write question. Does anybody know if it is possible inherit class
from the CollectionEdito r and change the behavior of newly inherited class?
Thanks.
B.
Apr 13 '06 #7

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

Similar topics

5
2757
by: Guy | last post by:
Guys Hope someone can help me! I'm having real problems getting properties I type against a control I have written at design time I have written a control by inheriting from the Button control. I am trying to add a feature whereby the control changes to a different color when the mouse floats over it, or when the button has the focus. The color changing works if the 'LightColor' is set at runtime in code. However, if I draw the control on...
3
5797
by: Ryan Steckler | last post by:
I found this behavior while trying to implement a singleton class. Below is a somewhat more straight forward example, though admittedly less useful in real life. The basic problem is that when a static property of a class is called (StaticInit.MyProperty), the property code executes BEFORE the static members are initialized. This would lead one to assume that the static members would equate to null, but that isn't the case either. They...
3
1917
by: Andre Boeder | last post by:
In one of my test classes there is a code fragment like this: protected System.Collections.Hashtable pData; public System.Collections.Hashtable PData { get { //TODO: read PData from DB System.Console.WriteLine("GET Hashtable"); return pData;
2
1713
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 = LoadControl("../UserControls/ISJob/uctlJobGeneral.ascx");
5
1578
by: Simon | last post by:
Hi all, We have an ASP.NET 1.1 application running on IIS6 on Server 2003. Most of the base objects we are using in this application are taken from a windows application also written by us. We have used shared properties on some of these objects to enable caching of frequently used objects, so save fetching them from SQL every time. These shared properties vastly increase performance of our windows app.
6
3713
by: Steve Barnett | last post by:
I have created a user control that includes the following field: protected TreeColumn columns = new TreeColumn; This is accessed via an accessor as follows: pubilc TreeColumn Columns { get { return columns; } set { columns = value; } }
14
18294
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
4
1750
by: Shak | last post by:
Hi My code looks like the follwing: namespace A.B.C { .... private void foo() { A.B.C.Properties.Settings.Default.Save();
3
2815
by: Alex | last post by:
Hi all, I'm trying to create an arraylist of a user control class... I'm able to define the list and add objects (panels) to it, but I can access and of the panel properties using an index... Is there a way to do this, or do I need to copy each node into an interim handle of the correct class before manipulating it? ie,
0
9699
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
10536
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
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...
0
9114
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...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
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
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.