473,657 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

customized propertygrid

Hi,
I thought I could use the property grid to nicly
edit some of my data, however it seems to require each field to be a
property,
wich I didnt realise was implied in the name of it lol.

Is there a way to customize it so it can display and edit fields wich
are stored in a dictionary ?

the classes I have is basically a custom/user defined class,
where theres a list of allowable fields with type info read from a file,
and a list of actual fields wich have data in them wich are read from a
file,
and a list of defualt values, the list also contains information such as
group name etc..

It would be nice to distinguish fields wich have data other than defualt in
them.

Ive tried to work out how to custiomise it using the AddTabType
but it seems like it still requires property fields.

many thanks
Colin =^.^=
Jun 27 '08 #1
8 4809
Basically, you can do this by writing a custom property model - here
is an example:

http://groups.google.co.uk/group/mic...ea254ad3c6abf6

You can use either ICustomTypeDesc riptor or TypeDescription Provider to
implement this, and many, many things are possible. So please let me
know if you want more info, as it is an area that I can talk on in
quite depressing depth...

Marc
Jun 27 '08 #2
thanks,
it looks quite complicated and involved,
almost as difficult as writing a custom control,
actually I think what I might do is look into custom classes
and build a class with the properties and all the tags,
possibly even as a wrapper,
this might be useful when/if I come to work out what I need to
do to actually use them anyway.

I havnt used custom classes yet, ive only heard them mentioned,
but I might instead generate a c# file and compile it at runtime
and probably insert those back into the project on the next build.

Colin =^.^=

"Marc Gravell" <ma**********@g mail.comwrote in message
news:1e******** *************** ***********@k37 g2000hsf.google groups.com...
Basically, you can do this by writing a custom property model - here
is an example:

http://groups.google.co.uk/group/mic...ea254ad3c6abf6

You can use either ICustomTypeDesc riptor or TypeDescription Provider to
implement this, and many, many things are possible. So please let me
know if you want more info, as it is an area that I can talk on in
quite depressing depth...

Marc

Jun 27 '08 #3
Ive written an implementation for CustomTypeDescr iptor
and PropertyDescrip tor, wich pick up the neccessary information from my
files,
but im not sure how to now use this with the propertygrid ?

I seem to end up wadding thru tons of waffle for property grid,
and I cant see where you use it in the example you gave

many thanks
Colin =^.^=

"Marc Gravell" <ma**********@g mail.comwrote in message
news:1e******** *************** ***********@k37 g2000hsf.google groups.com...
Basically, you can do this by writing a custom property model - here
is an example:

http://groups.google.co.uk/group/mic...ea254ad3c6abf6

You can use either ICustomTypeDesc riptor or TypeDescription Provider to
implement this, and many, many things are possible. So please let me
know if you want more info, as it is an area that I can talk on in
quite depressing depth...

Marc

Jun 27 '08 #4
aha ok forget that it was so simple, I just pass a CustomTypeDescr iptor
into the selected object instead of the actual object.
I chose to keep this seperate from the object.

It works now, but I would like to be able to indicate if
the data is different from the defualt value,
I gues il see if theres a way to change the background colour or something.

thanks
Colin =^.^=
"colin" <co*********@nt world.NOSPAM.co mwrote in message
news:w%******** ********@newsfe 1-win.ntli.net...
Ive written an implementation for CustomTypeDescr iptor
and PropertyDescrip tor, wich pick up the neccessary information from my
files,
but im not sure how to now use this with the propertygrid ?

I seem to end up wadding thru tons of waffle for property grid,
and I cant see where you use it in the example you gave

many thanks
Colin =^.^=

"Marc Gravell" <ma**********@g mail.comwrote in message
news:1e******** *************** ***********@k37 g2000hsf.google groups.com...
>Basically, you can do this by writing a custom property model - here
is an example:

http://groups.google.co.uk/group/mic...ea254ad3c6abf6

You can use either ICustomTypeDesc riptor or TypeDescription Provider to
implement this, and many, many things are possible. So please let me
know if you want more info, as it is an area that I can talk on in
quite depressing depth...

Marc


Jun 27 '08 #5
Sorry for delay... weekend etc...

I've answered the default thing on your other thread.

Re the usage; you would normally give the object itself to the
PropertyGrid, although a facade is fine too...

Basically, PropertyGrid gets its values by calling
TypeDescriptor. GetProperties(y ourObject);

You can influence what TypeDescriptor returns in two ways; if your
object itself implements ICustomTypeDesc riptor, then it will use this;
this approach is useful if the properties change instance-by-instance
(such as with a DataTable / DataRowView). Alternatively; if the
properties are the same for all instances of the type, you can move
this out of the type by using a TypeDescription Provider and
associating that with the type (either through an attribute or a
call). For example, in one of my systems the "extended" values (key/
value pairs) are the same per type - i.e. every Customer has the same
set of extended values - so I use TypeDescription Provider.

What you have done is provide a "facade" - i.e. a *separate* object
that you give the grid instead of your actual object. This is also a
valid choice, but it might be harder to bind to some other controls.

If you can describe the setup a bit more I can probably knock up a
pretty complete example in either instance/type syntax...

Marc
Jun 27 '08 #6
"Marc Gravell" <ma**********@g mail.comwrote in message
news:01******** *************** ***********@u69 g2000hse.google groups.com...
Sorry for delay... weekend etc...

I've answered the default thing on your other thread.

Re the usage; you would normally give the object itself to the
PropertyGrid, although a facade is fine too...

Basically, PropertyGrid gets its values by calling
TypeDescriptor. GetProperties(y ourObject);

You can influence what TypeDescriptor returns in two ways; if your
object itself implements ICustomTypeDesc riptor, then it will use this;
this approach is useful if the properties change instance-by-instance
(such as with a DataTable / DataRowView). Alternatively; if the
properties are the same for all instances of the type, you can move
this out of the type by using a TypeDescription Provider and
associating that with the type (either through an attribute or a
call). For example, in one of my systems the "extended" values (key/
value pairs) are the same per type - i.e. every Customer has the same
set of extended values - so I use TypeDescription Provider.

What you have done is provide a "facade" - i.e. a *separate* object
that you give the grid instead of your actual object. This is also a
valid choice, but it might be harder to bind to some other controls.

If you can describe the setup a bit more I can probably knock up a
pretty complete example in either instance/type syntax...

Marc
thanks very much for your help, its been a bit confusing but
ive learned enough to get it to do what I want :)

I just need to add implemention for fields wich are themselves user defined
structs,
such as vectors wich are 3 floats x,y,z.
ive seen references as to how to do this.

basically the classes are not c# but a custom script language,
the non defualt fields are stored in the file
and theres a definition of the class in the file
and the user can create new classes.
I just store the field data in a dictionary for each object
and a similar dictionary for the field definitions.

the propertygrid seemed better than using a data grid,
especially as there are already catagory definitions.
the files are part of a 3d game, i was hoping to not clutter up the
objects classes so they look close to the definitions.

I also need to edit a large amount of complicated data,
and I find the data grid very slow for large data sets.

maybe one day il make my own cell based data editor.

Colin =^.^=
Jun 27 '08 #7
I just need to add implemention for fields wich are themselves user defined
structs,
Typically, you would implement your own TypeConverter, marking the
struct with TypeConverterAt tribute (to associate it), and override
GetProperties and GetPropertiesSu pported (return true) to provide the
custom properties. Since structs should generally be immutable, you
would also override GetCreateInstan ceSupported (return true) and
CreateInstance - these last two are necessary to make the properties
pseudo-editable; in fact, it will use CreateInstance to create a *new*
struct to assign to the container's property.

I can provide an example if you need, but I'm at the MSDN roadshow
(Cardiff) tomorrow, so it would have to wait until Tuesday ;-p

Marc
Jun 27 '08 #8
thanks,
Ive managed to get the custom structs working
with expanded fields getting edited and created if necessary.

I decided to combine everything into one class,
wich implements the ICustomTypeDesc riptor interface
and inherits PropertyDescrip tor, and has ExpandableObjec tConverter as a
typeconverter attribute.

I was dubious this would actually work but it seems to.
it saved a lot of shared data and/or function calls from one to the other.

I now need to do the same for a few of the custom structs wich are actually
implemented as ordinary structs, this would involve some reflection.

the custom structs are just simply implmented as dictionary<name ,object>
so its easy to look up the field by name and get the data wich may also be
another dictionary.
I might look into using the internal custom struct to see if it could mean
sharing the code with the reflection.

Colin =^.^=
"Marc Gravell" <ma**********@g mail.comwrote in message
news:01******** *************** ***********@l64 g2000hse.google groups.com...
>I just need to add implemention for fields wich are themselves user
defined
structs,

Typically, you would implement your own TypeConverter, marking the
struct with TypeConverterAt tribute (to associate it), and override
GetProperties and GetPropertiesSu pported (return true) to provide the
custom properties. Since structs should generally be immutable, you
would also override GetCreateInstan ceSupported (return true) and
CreateInstance - these last two are necessary to make the properties
pseudo-editable; in fact, it will use CreateInstance to create a *new*
struct to assign to the container's property.

I can provide an example if you need, but I'm at the MSDN roadshow
(Cardiff) tomorrow, so it would have to wait until Tuesday ;-p

Marc

Jun 27 '08 #9

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

Similar topics

6
2892
by: Terry | last post by:
I have a very basic program, but for some reason I can't get it to behave properly. What I want is a basic form with a TabControl that fills the entire form. The tab control should have 4 tabs with a single PropertyGrid control on each tab that fills it's parent's tab page's client area. Here's what I did. 1. Create a new project.
3
6041
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 when I open the application for the first time. If, however, I open the form and then open a second...
1
11872
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 beyond the simple examples shown in online samples. All the online samples show how to take a class...
1
2569
by: Lance | last post by:
Is there any way to tell a Windows.Forms.PropertyGrid to update the values for the properties that it is displaying? I am having trouble getting the PropertyGrid to update when I make changes to the SelectedObject's properties outside of the PropertyGrid. If I use the PropertyGrid to change the SelectedObject's properties then everything works as expected (even when one property causes another property to change, etc.). But, if I...
7
9707
by: siddhiash | last post by:
Hi Friends I want to add PasswordChar Property which shows ****** for string which I type in PropertyGrid Control. Regards, Siddharth
6
6931
by: Steve Teeples | last post by:
Can someone show me an example of how to place a "CheckedListBox" property within a PropertyGrid? -- ----------- Thanks, Steve
5
15331
by: Sharon | last post by:
I'm using the PropertyGrid control, and I want it to show a button. But I set the PropertyGrid.SelectedObject with a object that as a Button property, the PropertyGrid shows the buttons properties, and I want the button to be shown as drawn and clickable button. How can I do that? -- Thanks Sharon
4
18816
by: phcmi | last post by:
I have a PropertyGrid question. My task is to replace a legacy dialog box presentation with a modern one. The dialog itself allows the user to set configuration settings in our application, so it seems to me that a PropertyGrid is a perfect modern replacement. I won't bore you with the details with all the controls on the dialog since I'm only concerned with one issue. The legacy dialog contains a drop down list control that is...
3
4348
by: =?Utf-8?B?U3RldmVU?= | last post by:
Is it possible to hide a row within a PropertyGrid based upon the boolean value of another row within the PropertyGrid? I am using VS2005 with .NET Frameworks 2.0. -- ----------- Thanks, Steve
0
8842
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
8740
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
8516
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
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
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
6176
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
5642
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
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.