473,653 Members | 2,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to change the item type display name in pop up collectionedito r

Hi,
I have my property editor wich uses the pop up
collection editor for arrays etc,
but i have had to use a generic wrapper for the
elements in some types of collections.

although the editing actually works well,
and I can set the name ok in the primary property editor,
this makes a mess of the type name displayed in the pop up colection editor,
is there any way to change this ?

eg

class UWrapper<T>:Lis t<T>
{
T Item{get{}}
}
UWrapper<Vector collection;

the collection gets displayed as UWrapper'1
in the title and also the same in the edit value box.

but I would like this to be displayed as Vector or whatever
the generic type is im using.

Ive tried all sorts of attributes and classes but cant seem
to figure this onr out. the pop up colection editor
seems to work diferently than the property editor.
Many thanks
Colin =^.^=



Jun 27 '08 #1
7 3801
oops that shoud of been

class UCollection<T>: List<T>
{
T Item{get{}}
}

public class UWrapper<T>
{
}

UCollection<UWr apper<Vector>co llection;

"colin" <co*********@nt world.NOSPAM.co mwrote in message
news:Nm******** ***********@new sfe30.ams2...
Hi,
I have my property editor wich uses the pop up
collection editor for arrays etc,
but i have had to use a generic wrapper for the
elements in some types of collections.

although the editing actually works well,
and I can set the name ok in the primary property editor,
this makes a mess of the type name displayed in the pop up colection
editor,
is there any way to change this ?

eg

class UWrapper<T>:Lis t<T>
{
T Item{get{}}
}
UWrapper<Vector collection;

the collection gets displayed as UWrapper'1
in the title and also the same in the edit value box.

but I would like this to be displayed as Vector or whatever
the generic type is im using.

Ive tried all sorts of attributes and classes but cant seem
to figure this onr out. the pop up colection editor
seems to work diferently than the property editor.
Many thanks
Colin =^.^=



Jun 27 '08 #2
Well, the following shows a way to customise the title (there may be
simpler ways, but I can't see them). Obviously you'd need to put some
different code in around ".Text = " to put in some code (presumably
using reflection and GetGenericTypeD efinition() etc) to put in a more
useful name...

using System;
using System.Collecti ons.ObjectModel ;
using System.Componen tModel;
using System.Componen tModel.Design;
using System.Drawing. Design;
using System.Windows. Forms;

class CollectionEdito r<T: CollectionEdito r
{
protected override CollectionForm CreateCollectio nForm()
{
CollectionForm form = base.CreateColl ectionForm();
form.Text = "Here be thee " + typeof(T).Name + "s";
return form;
}
public CollectionEdito r() : base(typeof(T)) {}
}

class Foo
{
[Editor(typeof(C ollectionEditor <Bar>), typeof(UITypeEd itor))]
public Collection<BarB ars { get; private set; }

public Foo() {Bars = new Collection<Bar> ();}
}
class Bar
{
public string Name { get; set; }
public int Age { get; set; }
}
static class Program
{
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Run (new Form
{
Controls = {
new PropertyGrid {
Dock = DockStyle.Fill,
SelectedObject = new Foo()
}
}
});
}
}
Jun 27 '08 #3
ok cool, thanks il give that a go, ive also been
trying to see what it uses by looking at
the .net reflector tool.

I did try and fool it giving it the type of the inner type

(i found it picks this type by looking for the type of the
Item property wich is the this[int index};)

but giving the data as a list of wrappers, but although the title was
correct,
it complained it couldnt convert the items to the wrapper type
when it tried to save it.

I tried using converter, custom descriptor, and descriptor provider,
but it never seems to hit any of the functions that can be overiden
that i could use

Colin =^.^=

"Marc Gravell" <ma**********@g mail.comwrote in message
news:ez******** ******@TK2MSFTN GP04.phx.gbl...
Well, the following shows a way to customise the title (there may be
simpler ways, but I can't see them). Obviously you'd need to put some
different code in around ".Text = " to put in some code (presumably using
reflection and GetGenericTypeD efinition() etc) to put in a more useful
name...

using System;
using System.Collecti ons.ObjectModel ;
using System.Componen tModel;
using System.Componen tModel.Design;
using System.Drawing. Design;
using System.Windows. Forms;

class CollectionEdito r<T: CollectionEdito r
{
protected override CollectionForm CreateCollectio nForm()
{
CollectionForm form = base.CreateColl ectionForm();
form.Text = "Here be thee " + typeof(T).Name + "s";
return form;
}
public CollectionEdito r() : base(typeof(T)) {}
}

class Foo
{
[Editor(typeof(C ollectionEditor <Bar>), typeof(UITypeEd itor))]
public Collection<BarB ars { get; private set; }

public Foo() {Bars = new Collection<Bar> ();}
}
class Bar
{
public string Name { get; set; }
public int Age { get; set; }
}
static class Program
{
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Run (new Form
{
Controls = {
new PropertyGrid {
Dock = DockStyle.Fill,
SelectedObject = new Foo()
}
}
});
}
}

Jun 27 '08 #4
well that does indeed set the title nicely,
however I doscovered you cant put template parameter inside attributes,

so this didnt work :-

public class UListWrap<T>
{
[Editor(typeof(U CollectionEdito r<T>), typeof(UITypeEd itor))]
// ^-- error CS0416:
// 'type parameter': an attribute argument cannot use type parameters
public class UDescWrap : CustomTypeDescr iptor
{
UColection<Tdat a;
... GetProperties() etc ...
}
}

I cant avoid the generic becuase i cant see any other way of getting
the type name at the time CreateCollectio nForm is called.

also the type of the object still apears as the typename of the wrapped
object
wich would be something like "UWrap'1"

oh and I also have to generate the generic type in reflection
(wich ive manged to do ok)
so i have no clue what T might be at run time.

I dont need to use any of this for simple types like int anyway,
but some of the items in some lists need to be able to get
the list of properties from the class that contains the list.

im thinking instead of using my own wrapper that I could use
typedescriptorp rovider for each object in the list
isntead of aplying it to a type, wich aplies to al objects of that type.

interestingly i was looking at the arraycolectione ditor in reflector
and it uses a fairly simple wrapper like mine.

its just the type name that apears obscure thats driving me mad
and thats only in the pop up colection editor,
the rest works ok, am I just being too pedantic ?

many thanks again
Colin =^.^=

ps if i ever get this sorted il post the complete solution
somewhere like code project ...

"Marc Gravell" <ma**********@g mail.comwrote in message
news:ez******** ******@TK2MSFTN GP04.phx.gbl...
Well, the following shows a way to customise the title (there may be
simpler ways, but I can't see them). Obviously you'd need to put some
different code in around ".Text = " to put in some code (presumably using
reflection and GetGenericTypeD efinition() etc) to put in a more useful
name...

using System;
using System.Collecti ons.ObjectModel ;
using System.Componen tModel;
using System.Componen tModel.Design;
using System.Drawing. Design;
using System.Windows. Forms;

class CollectionEdito r<T: CollectionEdito r
{
protected override CollectionForm CreateCollectio nForm()
{
CollectionForm form = base.CreateColl ectionForm();
form.Text = "Here be thee " + typeof(T).Name + "s";
return form;
}
public CollectionEdito r() : base(typeof(T)) {}
}

class Foo
{
[Editor(typeof(C ollectionEditor <Bar>), typeof(UITypeEd itor))]
public Collection<BarB ars { get; private set; }

public Foo() {Bars = new Collection<Bar> ();}
}
class Bar
{
public string Name { get; set; }
public int Age { get; set; }
}
static class Program
{
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();
Application.Run (new Form
{
Controls = {
new PropertyGrid {
Dock = DockStyle.Fill,
SelectedObject = new Foo()
}
}
});
}
}

Jun 28 '08 #5
Darn, you beat me to it... I was going to suggest
TypeDescription Provider ;-p

As for pedantic - well: it is your system; does the effort justify it?
Only you can answer that...

Marc
Jun 29 '08 #6

"Marc Gravell" <ma**********@g mail.comwrote in message
news:43******** *************** ***********@m45 g2000hsb.google groups.com...
Darn, you beat me to it... I was going to suggest
TypeDescription Provider ;-p

As for pedantic - well: it is your system; does the effort justify it?
Only you can answer that...

Marc
well the typedescriptorp rovidor works for the pop up class but it breaks the
property window
i get null being passed to my MyPropertyDesri pptor::getvalue (object
component)

as for being pedantic this has now become a challange of wits and
im not prepared to give in !!!

maybe the learning process may yeild some value.

thanks
Colin =^.^=
Jul 6 '08 #7
I think i might of found a better way now,
I use type delegator wich wraps my array type
and overides GetElementType to return
another typedelegator wich wraps my element type
and overides Name to return the inner type.

im not sure how this extends to other collections yet,
or how useful it will be to use in place of a whole collection
of classes.

but it is just one class with a couple of simple functions.

Colin
"Marc Gravell" <ma**********@g mail.comwrote in message
news:43******** *************** ***********@m45 g2000hsb.google groups.com...
Darn, you beat me to it... I was going to suggest
TypeDescription Provider ;-p

As for pedantic - well: it is your system; does the effort justify it?
Only you can answer that...

Marc

Jul 7 '08 #8

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

Similar topics

0
1330
by: Buzz Bonner | last post by:
Hi, I need to perform some validation on the items inserted into the CollectionEditor. How can I override the CollectionEditor OK button so that the editor doesn't close if a validation error is raised?
4
18468
by: Richard Trahan | last post by:
(This is a repost -- the original got tucked away into an old thread because I used the same Subject name.) I'm trying to change the document title to add an asterisk when the document becomes "dirty", as seen on editor applications. I use the code below. Venkman shows that everything looks as expected. The last line is for the debugger, which indicates that the title is changed, but it does not display.
3
26498
by: Noozer | last post by:
I have several tags on a webpage of the same class. If the user clicks a specific checkbox I'd like to be able to alter the display property of the class, affecting all objects of that class. This is an intranet application so we know that javascript will be enabled and the browser will be IE. How can I affect all the members of this class? Is there a way I can toggle the DISPLAY property of a class so all the elements using that class...
3
9459
by: Ronald S. Cook | last post by:
Hi all, I have an ASP.NET DataGrid wherein there is an edit link for each row. Upon clicking the link, certan fields in that row display in text boxes so that they may be edited. I would like some textboxes to be wider, some narrower. By default, they are all the same pre-defined width. Does anyone know how I can do this? Thanks very much,
13
4169
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture' , data type='Number' ,Display Control='Combo Box', RowSource Type = 'Value List' and Row Source = ' 0;"chair";1;"Table";2;"Bed" ' Therefore, in data sheet view of table, if we select (1 : Table ) ,
0
1050
by: Henry J. | last post by:
Is there a way to find the element currently selected in a CollectionEditor where a collection is displayed? For PropertyGrid one can use something like SelectedGridItems to get the currently selected property in a PropertyGrid. But I failed to find anything for the selected element in a CollectionEditor. Thanks for any tips!
4
2429
by: gregincolumbus | last post by:
I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes. Ideally, a change of select1 1. trigger the population of select2 (and set it initially to 0) 2. make the text fields disappear 3. trigger the financial calculation to reflect the select1 choice. Any help would be greatly appeciated !
0
5970
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I have a listview that when I select an item, it populates a details view. I want to show the item that was selected in the listview by changing it to yellow. Trouble is, the selected item does not show as yellow until I've clicked the same item two times. What am I doing wrong on the selected item that keeps it from changing to yellow until the item is clicked two times? Also, I have to set the listviews selectedIndex in the...
0
8370
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
8811
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...
1
8470
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
7302
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
6160
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
5620
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
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
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.