473,786 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to apply propertygrid's attributes to existing object?

I have assigned an existing object to propertygrid.se lectedobject property.
But I only want some of the object's properties not browsable and/or
readonly. How can I do that?

I'm trying to find information about propertygrid but most of the
information seems to be for VS2003.
Oct 2 '07 #1
4 5102
On Oct 2, 5:07 pm, Peter <Pe...@discussi ons.microsoft.c omwrote:
I have assigned an existing object to propertygrid.se lectedobject property.
But I only want some of the object's properties not browsable and/or
readonly. How can I do that?

I'm trying to find information about propertygrid but most of the
information seems to be for VS2003.
Check out the BrowsableAttrib ute class. You can decorate your
properties and methods with it to indicate which ones you want visible
in the property grid.

Another way would be to create an adapter object that contains an
instance of the "real" object and only expose the properties that you
need.

Chris

Oct 3 '07 #2
Hi Chris,

I think the BrowsableAttrib ute class is only useful if I have control on the
class coding. The object assigned to propertygrid is an object returned by
a .NET method so I have no direct way to change the attribute. Based on
what I have found so far, I think it is possible to change the attribute of
the existing object using reflection but I need to learn reflection first if
that is the only way.

Can you elaborate about the adapter object way?

"Chris Dunaway" wrote:
On Oct 2, 5:07 pm, Peter <Pe...@discussi ons.microsoft.c omwrote:
I have assigned an existing object to propertygrid.se lectedobject property.
But I only want some of the object's properties not browsable and/or
readonly. How can I do that?

I'm trying to find information about propertygrid but most of the
information seems to be for VS2003.

Check out the BrowsableAttrib ute class. You can decorate your
properties and methods with it to indicate which ones you want visible
in the property grid.

Another way would be to create an adapter object that contains an
instance of the "real" object and only expose the properties that you
need.

Chris

Oct 3 '07 #3
Hello Peter,

On the PropertyGrid Resource List (http://
www.propertygridresourcelist.com), you will find a lot of
informations. One of the links of the list points to a Microsoft
article where the TypeDescription Provider (new in .net 2.0) is
explained. From the article:

"This allows you to write a separate class that implements
ICustomTypeDesc riptor and then to register this class as the provider
of descriptions for other types".

This is here: http://msdn.microsoft.com/msdnmag/is...05/NETMatters/

I hope this helps.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor .Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Oct 3, 2:11 pm, Peter <Pe...@discussi ons.microsoft.c omwrote:
Hi Chris,

I think the BrowsableAttrib ute class is only useful if I have control on the
class coding. The object assigned topropertygridi s an object returned by
a .NET method so I have no direct way to change the attribute. Based on
what I have found so far, I think it is possible to change the attribute of
the existing object using reflection but I need to learn reflection first if
that is the only way.

Can you elaborate about the adapter object way?

"Chris Dunaway" wrote:
On Oct 2, 5:07 pm, Peter <Pe...@discussi ons.microsoft.c omwrote:
I have assigned an existing object topropertygrid. selectedobject property.
But I only want some of the object's properties not browsable and/or
readonly. How can I do that?
I'm trying to find information aboutpropertygr idbut most of the
information seems to be for VS2003.
Check out the BrowsableAttrib ute class. You can decorate your
properties and methods with it to indicate which ones you want visible
in the property grid.
Another way would be to create an adapter object that contains an
instance of the "real" object and only expose the properties that you
need.
Chris

Oct 4 '07 #4
On Oct 3, 1:11 pm, Peter <Pe...@discussi ons.microsoft.c omwrote:
Hi Chris,

I think the BrowsableAttrib ute class is only useful if I have control on the
class coding. The object assigned to propertygrid is an object returned by
a .NET method so I have no direct way to change the attribute. Based on
what I have found so far, I think it is possible to change the attribute of
the existing object using reflection but I need to learn reflection first if
that is the only way.

Can you elaborate about the adapter object way?
I simply meant create another class that acts as a container to the
class you want to limit the properties for and then only expose the
properties you want:

Public Class AdapaterClass

'classToLimit has lots of properties, but we only want some of
them
'visible in the PropertyGrid

Private _instance As classToLimit

Public Sub New(object As classToLimit )
_instance = object
End Sub

Public Property Property1() As String
Get
Return _instance.Prope rty1
End Get
Set
_instance.Prope rty1 = Value
End Set
End Property

Public Property Property2() As String
Get
Return _instance.Prope rty2
End Get
Set
_instance.Prope rty2 = Value
End Set
End Property

<Browsable(Fals e)_
Public ReadOnly Property Instance() As classToLimit
Get
Return _instance
End Get
End Property

End Class

Then you add an instance of the AdapterClass to the PropertyGrid.

I think VisualHint's suggestion is probably the way to go, but this
method, at least, is easy.

Chris

Oct 4 '07 #5

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

Similar topics

3
7315
by: Nicolas | last post by:
I want to display in my application a PropertyGrid showing only the "Appearance" of a control (ie. textBox) so the user can change it. Bare with me, I'm new in csharp. Where do I go from: this.PropertyGrid1.SelectedObject = this.Textbox1; Thank a lot
2
3982
by: Mevar81 | last post by:
Hi to everybody.I have a problem with the PropertyGrid control.I want to display not all the properties of a generic Control(Button,TextBox,ComboBox,ecc.).In general I don't want to display only one category(Appearance, Behavior,ecc.) but I want to chose directly which properties to show.I've read that I can use the SelectedObjects to put an array of object with some properties in common with the SelectedObject,and only properties in...
1
11887
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...
4
3074
by: Bernie Yaeger | last post by:
How can I set the browsableattributes of the control that has been selected (selectedobject) by the propertygrid? Here's what I'm after - I want to open a form with a propertygrid in it. The selectedobject will be the form itself. I want the user to change certain properties, thus changing the form. This works fine, but what I really want is to take the changes and lock them into a config file, such that this pc will then display all...
5
6545
by: Lance | last post by:
I want to expose properties of a class to a user via a PropertyGrid class. Some of the properties are of type System.IO.FileInfo. Ideally, an OpenFileDialog window would appear when the user attempted to edit the value of the System.IO.FileInfo properties. Is there an existing UITypeEditor that will do this type of thing, or will I need to create my own Thanks Lance
0
2661
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem I am having is that when I have a value in the propertygird and edit that, I want the listbox to have the selectvalue equal to the value that is being edited. Just to make it clearer: PropgridVal = Germany Datasource=
0
1551
by: Marco Segurini | last post by:
HI, my form contains a combobox and a propertygrid control. At each string of the combobox is associated an object. When I select a string of the combobox the associated object is selected in the propertygrid in this way: this.propertyGrid1.SelectedObject = aObject; this.propertyGrid1.Refresh();
0
1535
by: movieknight | last post by:
Hi, I have a class which I am feeding to the propertygrid, and I am exposing a Mesh object from my class for the propertygrid to display. I want the propertygrid to show the values (when you expand the property) and allow those values to be edited. My code is below. The grid is showing the values but they are read-only, although the other properties for the rest of my class are editable. Public Class MeshConverter
4
18826
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...
0
9647
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...
1
10108
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
9960
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
8988
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
7510
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
6744
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
5397
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...
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
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.