472,992 Members | 3,296 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

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 4769
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 ICustomTypeDescriptor or TypeDescriptionProvider 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**********@gmail.comwrote in message
news:1e**********************************@k37g2000 hsf.googlegroups.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 ICustomTypeDescriptor or TypeDescriptionProvider 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 CustomTypeDescriptor
and PropertyDescriptor, 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**********@gmail.comwrote in message
news:1e**********************************@k37g2000 hsf.googlegroups.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 ICustomTypeDescriptor or TypeDescriptionProvider 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 CustomTypeDescriptor
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*********@ntworld.NOSPAM.comwrote in message
news:w%****************@newsfe1-win.ntli.net...
Ive written an implementation for CustomTypeDescriptor
and PropertyDescriptor, 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**********@gmail.comwrote in message
news:1e**********************************@k37g2000 hsf.googlegroups.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 ICustomTypeDescriptor or TypeDescriptionProvider 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(yourObject);

You can influence what TypeDescriptor returns in two ways; if your
object itself implements ICustomTypeDescriptor, 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 TypeDescriptionProvider 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 TypeDescriptionProvider.

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**********@gmail.comwrote in message
news:01**********************************@u69g2000 hse.googlegroups.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(yourObject);

You can influence what TypeDescriptor returns in two ways; if your
object itself implements ICustomTypeDescriptor, 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 TypeDescriptionProvider 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 TypeDescriptionProvider.

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 TypeConverterAttribute (to associate it), and override
GetProperties and GetPropertiesSupported (return true) to provide the
custom properties. Since structs should generally be immutable, you
would also override GetCreateInstanceSupported (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 ICustomTypeDescriptor interface
and inherits PropertyDescriptor, and has ExpandableObjectConverter 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**********@gmail.comwrote in message
news:01**********************************@l64g2000 hse.googlegroups.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 TypeConverterAttribute (to associate it), and override
GetProperties and GetPropertiesSupported (return true) to provide the
custom properties. Since structs should generally be immutable, you
would also override GetCreateInstanceSupported (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
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...
3
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...
1
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...
1
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...
7
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
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
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,...
4
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...
3
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,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.