473,382 Members | 1,387 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,382 software developers and data experts.

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.ComponentModel.ITypeDescriptorContext, ByVal sourceType As
System.Type) As Boolean
If sourceType.ToString = "System.String" Then
Return True
Else
Return MyBase.CanConvertFrom(context, sourceType)
End If
End Function

Public Overrides Function CanConvertTo(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As
System.Type) As Boolean
Return False
End Function

Public Overrides Function ConvertTo(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal culture As
System.Globalization.CultureInfo, ByVal value As Object, ByVal
destinationType As System.Type) As Object
If destinationType Is Nothing Then
Throw New ArgumentNullException("destinationType")
ElseIf value.ToString = "Microsoft.DirectX.Direct3D.Mesh" Then
Return "Mesh Object"
Else
Return MyBase.ConvertTo(context, culture, value,
destinationType)
End If
End Function

Public Overrides Function GetProperties(ByVal context As
System.ComponentModel.ITypeDescriptorContext, ByVal value As Object,
ByVal attributes() As System.Attribute) As
System.ComponentModel.PropertyDescriptorCollection
Return TypeDescriptor.GetProperties(GetType(Mesh)) '
MyBase.GetProperties(context, value, attributes)
End Function

Public Overrides Function GetPropertiesSupported(ByVal context As
System.ComponentModel.ITypeDescriptorContext) As Boolean
Return True
End Function
End Class

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

<TypeConverter(GetType(MeshConverter))> _
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 1509

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

Similar topics

1
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...
3
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 ...
2
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...
1
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...
2
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...
2
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...
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...
3
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.