473,388 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Dynamic Property grid problem

Hi,

I have a problem with dynamically putting dynamic properties on the property
grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron
Oct 23 '06 #1
6 2439
I haven't worked with the grid a lot, just played around a few...

But from my experience, whatever object you bind it to, it will show the
properties of that object, as it is able, with respect to attributes set on
the properties and available type-converters if needed.

If you have just some set of variables, you want to show in there, I would
think you would have to wrap them in a MyVars class or something along those
lines (maybe a struct would work?). Then make an instance of your class, and
bind the grid to that instance.

HTH.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:u5**************@TK2MSFTNGP04.phx.gbl...
Hi,

I have a problem with dynamically putting dynamic properties on the
property grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron
Oct 23 '06 #2
Hi,

Unfortunately, I am getting my list of properties and their type at runtime
and I can't "wrap" any classes there". My app can get information like: "
hey, this object now has AGE and it's an integer" at any given moment and I
need the property grid to reflect that.

Ron

"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:5E**********************************@microsof t.com...
>I haven't worked with the grid a lot, just played around a few...

But from my experience, whatever object you bind it to, it will show the
properties of that object, as it is able, with respect to attributes set
on the properties and available type-converters if needed.

If you have just some set of variables, you want to show in there, I would
think you would have to wrap them in a MyVars class or something along
those lines (maybe a struct would work?). Then make an instance of your
class, and bind the grid to that instance.

HTH.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:u5**************@TK2MSFTNGP04.phx.gbl...
>Hi,

I have a problem with dynamically putting dynamic properties on the
property grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron

Oct 23 '06 #3
What or where are the properties and notifications coming from??
"Ron M. Newman" <co**********@confideltial.comwrote in message
news:#X**************@TK2MSFTNGP03.phx.gbl...
Hi,

Unfortunately, I am getting my list of properties and their type at
runtime and I can't "wrap" any classes there". My app can get information
like: " hey, this object now has AGE and it's an integer" at any given
moment and I need the property grid to reflect that.

Ron

"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:5E**********************************@microsof t.com...
>>I haven't worked with the grid a lot, just played around a few...

But from my experience, whatever object you bind it to, it will show the
properties of that object, as it is able, with respect to attributes set
on the properties and available type-converters if needed.

If you have just some set of variables, you want to show in there, I
would think you would have to wrap them in a MyVars class or something
along those lines (maybe a struct would work?). Then make an instance of
your class, and bind the grid to that instance.

HTH.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:u5**************@TK2MSFTNGP04.phx.gbl...
>>Hi,

I have a problem with dynamically putting dynamic properties on the
property grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron

Oct 24 '06 #4
Hi Ron,

You can create a TypeConverter for your class and override the GetProperties
and GetPropertiesSupported methods. You can add, remove or change the
properties being displayed for any Component that is defined with your
TypConverter via a TypeConverterAttribute. TypeConverterAttribute can also be
declared on properties in your class to control their behavior in the
PropertyGrid as well.

In the GetProperties method, you can use methods from the
System.ComponentModel.PropertyDescriptor class to populate a new
PropertyDescriptorCollection. In your TypeConverter you can also subclass
SimplePropertyDescriptor, a nested and protected class in the TypeConverter
class, which is an easy way to define your own simple properties.

The FCL defines many *Converter implementations that you can use as well. One
particularly interesting TypeConverter is the ExpandableObjectConverter, which
you can assign to properties of your own classes (via TypeConverterAttribute)
that are complex types and should be expandable in the PropertyGrid itself as
a +/- node.

--
Dave Sexton

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:u5**************@TK2MSFTNGP04.phx.gbl...
Hi,

I have a problem with dynamically putting dynamic properties on the property
grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron

Oct 24 '06 #5
Hello Ron,

Dave is right, you can use the TypeConverter to publish a set of
dynamic properties. You can also derive your class from
ICustomTypeDescriptor. I recommend you to consult the Microsoft
PropertyGrid Resource List (see signature) and search by tag to target
the right articles.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
Ron M. Newman wrote:
Hi,

I have a problem with dynamically putting dynamic properties on the property
grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron
Oct 24 '06 #6
If you're doing what I think your doing then you definitely need to look at
the TypeDescriptor.AddProvider method, the TypeDescriptionProvider class and
use your imagination.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Ron M. Newman" <co**********@confideltial.comwrote in message
news:u5**************@TK2MSFTNGP04.phx.gbl...
Hi,

I have a problem with dynamically putting dynamic properties on the
property grid. My app has no idea what it'll be showing at compile time.

How do I dynamically add properties to the property grid?

Thanks,
Ron

Oct 24 '06 #7

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
0
by: SlipperyCat | last post by:
I want to use the property grid to display instances of dynamic types. A problem I'm having is that the property grid is not respecting attributes that are set with SetCustomAttribute. I've taken...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
0
by: Andreas Poller | last post by:
Hi, I want to customize a Property Grid in the following way: The Property Grid should show a property which value should be changed by a dropdown-listbox. For example, there is a property...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
4
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
0
by: Joe | last post by:
Hi I am trying to allow my property grid have a property with the values are dynamically generated at runtime I can create a static list but not dynamic Anyone have a suggestion or code...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.