473,574 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expanded ReadOnly Array Elements in PropertyGrid

If a property's type is an array and the property is exposed in a
PropertyGrid, then the property can be expanded so that the user can view and
edit the array elements. But, I've noticed that if the property is ReadOnly
then the expanded array elements can still be edited. I need to make the
elements ReadOnly if the property is ReadOnly. Is this possible?

Thank you,
Lance

Nov 21 '05 #1
8 5222
Hi

Now I am researching the issue and I will update you with new information
ASAP.
Also I think you may try to post in the designtime specifed queue, so that
there will be more experienced designtime guys helps you.

microsoft.publi c.dotnet.framew ork.windowsform s.designtime

Thanks for you understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Hi Lance,

I think it is by design, because the ReadOnly Property will return an
Array, while the Array is not readonly.
The workaround is changing the array to an ArrayList and returning the
array through the ArrayList.ReadO nly wrapper.

e.g.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
'
'UserControl1
'
Me.Name = "UserContro l1"
Me.strs.Add("Te st")
Me.Size = New System.Drawing. Size(248, 240)

End Sub
Dim strs As New ArrayList
Public ReadOnly Property TestArray() As Object()
Get
Return ArrayList.ReadO nly(strs).ToArr ay()
End Get
End Property

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
Thank you for the idea. My hope was that I could inherit from
System.Componen tModel.ArrayCon verter (or some other class) and modify its
behavior so that the expanded elements are ReadOnly. Do you know if that is
possible?

Also, please let me know if you would prefer to have me repost this thread
on the microsoft.publi c.dotnet.framew ork.windowsform s.designtime group.

Thanks again,
Lance

Nov 21 '05 #4
Hi Lance,

For this issue, we will do some research into PointConverter class. We will
update you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 21 '05 #5
Hi Lance,

I think this issue should be the same problem as another your post
"TypeConver ters for Float Drawing Structures". I have posted a reply to you
in that thread, you may follow up there. I will keep up with you there.
Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 21 '05 #6
Jeffrey,

Thanks again for you help with "TypeConver ters for Float Drawing
Structures". I applied the same technique (i.e., overriding
GetCreateInstan ceSupported to return True) to a class that inherits from
ArrayConverter (e.g., MyArrayConverte r) and the result is very close to the
desired behavior. But, I still have one issue and one question:

1. If a property is ReadOnly and the property type is a jagged array (e.g.,
Double()()) then the list of expanded elements that correspond to the first
dimension are disabled (i.e., ReadOnly), but expanded elements of the other
dimensions are enabled. Is there any way to make all of the array elements
disabled?

2. I've included my code for overriding CreateInstance in the modified
ArrayConverter. Can you please comment on whether or not there is a better
technique? Of particular concern is the For loop which is very inefficient.
For example, can it be assumed that the items in propertyValues. Values are in
the appropriate order so that propertyValues. Values.CopyTo can be used
instead of the For loop?

Public Overloads Overrides Function CreateInstance( ByVal context As
System.Componen tModel.ITypeDes criptorContext, ByVal propertyValues As
System.Collecti ons.IDictionary ) As Object
If ((context Is Nothing) OrElse (context.Proper tyDescriptor Is
Nothing) OrElse (Not context.Propert yDescriptor.Pro pertyType.IsArr ay)) Then
Return Nothing
End If

If ((propertyValue s Is Nothing) OrElse (propertyValues .Count = 0)) Then
Return Nothing
End If

'Create an array of the appropriate type and length.
Dim arrayElementTyp e As System.Type =
context.Propert yDescriptor.Pro pertyType.GetEl ementType
Dim array As System.Array =
System.Array.Cr eateInstance(ar rayElementType, propertyValues. Count) 'Return
value.

'Set the elements of the array.
Dim key As String
For i As Integer = 0 To array.GetUpperB ound(0)
key = "[" & i.ToString & "]"
array.SetValue( propertyValues( key), i)
Next i

Return array
End Function

Thanks,
Lance

Nov 21 '05 #7
Hi Lance,

Thanks for your feedback!!

Defaultly for jagged array, its second dimension should be a collection
editor dialog, while not in an expandable state. Can you show me how you
implement your jagged array and jagged array typeconverter? I suggest you
create a sample project for us to demonstrate your problem(you can attach
the project in the reply in newsgroup), then we can track your issue better
and quicker.

I will wait for your further reply. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 21 '05 #8
Hi Lance,

Have you managed to create a sample reproduce project? Is your problem
resolved? Please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 21 '05 #9

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

Similar topics

4
22372
by: kaeli | last post by:
Hi all, I have form elements that I want to not be editable. They should, however, be passed on submission. AFAIK, then, they need to be readonly. (intranet app where elments are created server-side according to perms of user with a jsp taglib, so users get some elements they can edit and some they can't, but all will be passed to next...
0
2291
by: Saurabh Mishra | last post by:
I need to be able to make the entire PropertyGrid ReadOnly at times during runtime, and I am not exactly sure how to accomplish this. Making the PropertyGrid.Enabled = false is unacceptable since that doesnt allow one to scroll down if the GridList is too big. Any suggestions are welcome. Thanks in advance. Saurabh.
3
2686
by: Pol Bawin | last post by:
Hi All, One : I have a property that get/set a array of an abstract class A By default my array is null In the propertygrid, It is not works correctly when my array is null. (when my array is initialized with one element it works fine) But I can not change the initial state of the array. It must be null. what must I change.
2
2912
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
4556
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
1550
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...
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...
0
941
by: ljlevend | last post by:
I am exposing a property as an expandable property in a PropertyGrid by assigning a System.ComponentModel.TypeConverter attribute to the property. Is there any way to have the PropertyGrid group the expanded items in categories as is done with PropertyGrid.SourceObject's properties when PropertyGrid.PropertySort = CategorizedAlphabetical? ...
0
1525
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...
0
7808
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...
1
7822
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...
0
8101
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...
1
5626
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
5302
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
3742
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...
0
3754
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2249
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
0
1062
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.