473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

readonly properties when displaying an object's properties in propertygrid


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

Inherits TypeConverter

Public Overrides Function CanConvertFrom( ByVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal sourceType As
System.Type) As Boolean
If sourceType.ToSt ring = "System.Str ing" Then
Return True
Else
Return MyBase.CanConve rtFrom(context, sourceType)
End If
End Function

Public Overrides Function CanConvertTo(By Val context As
System.Componen tModel.ITypeDes criptorContext, ByVal destinationType As
System.Type) As Boolean
Return False
End Function

Public Overrides Function ConvertTo(ByVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal culture As
System.Globaliz ation.CultureIn fo, ByVal value As Object, ByVal
destinationType As System.Type) As Object
If destinationType Is Nothing Then
Throw New ArgumentNullExc eption("destina tionType")
ElseIf value.ToString = "Microsoft.Dire ctX.Direct3D.Me sh" Then
Return "Mesh Object"
Else
Return MyBase.ConvertT o(context, culture, value,
destinationType )
End If
End Function

Public Overrides Function GetProperties(B yVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal value As Object,
ByVal attributes() As System.Attribut e) As
System.Componen tModel.Property DescriptorColle ction
Return TypeDescriptor. GetProperties(G etType(Mesh)) '
MyBase.GetPrope rties(context, value, attributes)
End Function

Public Overrides Function GetPropertiesSu pported(ByVal context As
System.Componen tModel.ITypeDes criptorContext) As Boolean
Return True
End Function
End Class

I am new to this typeconverter stuff. My class property looks like
this:

<TypeConverter( GetType(MeshCon verter))> _
Public Property Mesh() As Direct3D.Mesh
Get
Return _mesh
End Get
Set(ByVal value As Direct3D.Mesh)
_mesh = value
End Set
End Property

This is the property I want to be able to view and edit within the
propertygrid when I pass the propertygrid my main class.

Can anybody see what I am doing wrong?

Thanks,

Richy

May 14 '06 #1
0 1523

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

Similar topics

1
1437
by: mrVithan | last post by:
I create a user control object and show its properties through a propertygrid object in my application. It is sure that there are 100 hundred of properties inherited from System.Windows.Forms.UserControl and they are all showed on the propertygrid. Is there a way i can hide all these inherited properties and show only my user control's...
3
5072
by: Martin Montgomery | last post by:
I have, for example, a property called myProperty. I would like, when using a property grid to display the property name as "My Property". Is this possible. Is there an attribute etc Thank Martin
2
2910
by: Alan | last post by:
Hi all, I have one class including one collection. I use propertygrid to display and edit its properties. I'm trying to use reflection to change the status of one element to be readonly, for example the first element in this collection.The result is that all of elements changed. I guess the ReadOnly attribute is for class(or type), not for...
1
4552
by: Polo | last post by:
I have a instance of a class A I show it in a propertyGrid. Sometime this object can be edited, sometime not (all properties readonly). How can i do it (Without the ReadOnlyAttrivute) Thank's in advance Polo
2
1298
by: Benny Raymond | last post by:
I'm working on a program that has a treeview, and each tree node refrences a row in my database. I really like how the properties section of the collections editor looks - is this a control that is available to use? I thought it was a datagrid, but I can't get the datagrid to show up like the collections properties thing. Any help would...
2
1549
by: Dave Wurtz | last post by:
All, Does anyone know how I can make the PropertyGrid control readonly? I want to display the PUBLIC properties of an object, but I don't want the user to be able to change them (they do need to be read/write internally, however). Along with this, if the property is a collection, the collection window should not allow the user to change...
0
5552
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 is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the...
3
4739
by: Tom | last post by:
I'm using the PropertyGrid, and have it bound to a class object. Works fine - however, I have some properties that I want to show up on the grid (i.e. they are browsable) -YET- I don't want the user to be able to change them; i.e. want them ReadOnly to the grid. I tried setting that classes property to the ReadOnly attrib, but it wouldn't take...
1
132
by: Brad Pears | last post by:
Perfect. That makes more sense then calling a method to run the Stored Proc and return the value in the read only properties "Get" method because then it would be running that everytime someone wants to use that value. Instead, run it once at object instantiation, then set it once to the private variable, then the read only properties get...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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. ...
0
6043
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...
1
5368
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...
0
5088
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...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
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
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
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...

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.