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

CollectionEditor once again

Hi all

I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection, and I have written a subclass of CollectionEditor to manipulate it, using an EditorAttribute on the collection class to associate the collection with my custom Editor subclass. The Collection Editor has its own little PropertyGrid, which displays the properties of the selected member of the collection. All OK so far..

The issue arises when the user adds a new object to the collection using the Add button in the CollectionEditor. In my collection class (which is derived from CollectionBase) I have overridden the OnValidate method to do a little tweaking of the object (adding an ID) before it is added to the collection. The way the CollectionEditor seems to do this is by calling its CreateInstance() method to generate the new object, populating its local PropertyGrid with the new object's properties, then inserting it into the collection. The problem is that I am modifying the object's property values just before the new object inserted -- but this is AFTER the CollectionEditor's local PropertyGrid has been loaded with the property values. Consequently what is displayed are the values PRIOR to the object's insertion, and the display is not refreshed! I can find no methods in the CollectionEditor class for refreshing the display, nor can I see any way of getting access to the CollectionEditor's PropertyGrid control. So the user won't see the real values of the new object's properties until he clicks OK, and then reopens the editor

Any ideas? I realize this is a pretty arcane problem.. :-

Thanks, MP
Nov 22 '05 #1
2 2190
I am not seeing that behaviour here. If I modify the Object in the
CollectionBase Class's OnValidate() Method
then the Editor shows the modified property.

"m. pollack" <an*******@discussions.microsoft.com> wrote in message
news:ED**********************************@microsof t.com...
Hi all,

I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection,
and I have written a subclass of CollectionEditor to manipulate it, using an
EditorAttribute on the collection class to associate the collection with my
custom Editor subclass. The Collection Editor has its own little
PropertyGrid, which displays the properties of the selected member of the
collection. All OK so far...
The issue arises when the user adds a new object to the collection using the Add button in the CollectionEditor. In my collection class (which is
derived from CollectionBase) I have overridden the OnValidate method to do a
little tweaking of the object (adding an ID) before it is added to the
collection. The way the CollectionEditor seems to do this is by calling its
CreateInstance() method to generate the new object, populating its local
PropertyGrid with the new object's properties, then inserting it into the
collection. The problem is that I am modifying the object's property values
just before the new object inserted -- but this is AFTER the
CollectionEditor's local PropertyGrid has been loaded with the property
values. Consequently what is displayed are the values PRIOR to the object's
insertion, and the display is not refreshed! I can find no methods in the
CollectionEditor class for refreshing the display, nor can I see any way of
getting access to the CollectionEditor's PropertyGrid control. So the user
won't see the real values of the new object's properties until he clicks OK,
and then reopens the editor.
Any ideas? I realize this is a pretty arcane problem.. :-(

Thanks, MP

Nov 22 '05 #2
Hi Mick,

hmmm... here's what I've found -- the display is updated, like you say, if I do nothing in OnValidate() besides modify the member value. However, I had been displaying a messagebox to the user at this point, and when I do that, then the grid only shows the pre-modification values.

There must be some sort of threading issue here. I actually have to make some method calls to get the new values, and I'm wondering if we have a race going on, and if the result depends on how long it takes to fetch the values I need. I thought the whole thing would happen synchronously, but I guess not!

Thanks, MP
Nov 22 '05 #3

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

Similar topics

2
by: m. pollack | last post by:
Hi all I've been using the PropertyGrid to allow the user to edit a class object at runtime. The class object contains a custom strongly-typed collection, and I have written a subclass of...
0
by: m. pollack | last post by:
<I've reposted this here as it was slipping away over the horizon on the C# group Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to...
0
by: Buzz Bonner | last post by:
Hi, I need to perform some validation on the items inserted into the CollectionEditor. How can I override the CollectionEditor OK button so that the editor doesn't close if a validation error is...
0
by: m. pollack | last post by:
Hi all I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control....
0
by: m. pollack | last post by:
<I've reposted this as it was slipping away over the horizon Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for...
0
by: juststarter | last post by:
Hello all, here is my problem. I am using a property grid control (in a vb.net 2003 project) in which two properties are exposed : "editorStyle" and "events". The first property is used to select...
0
by: Andreas | last post by:
Hi! I'm using a custom collection with custom items to be edited with a custom CollectionEditor. This set of functionality is to be a part of a plugin for a SharpDevelop-based application. The...
2
by: Henry J. | last post by:
Has anybody run into this index out range exception when opening and then closing a collectionEditor from within a PropertyGrid? I use PropertyGrid to edit configurations in my application. One...
0
by: Bardo | last post by:
Hi all, I am having an issue with a custom CollectionEditor. My scenario is as follows: I have a base type TypeA. I also have a TypeACollection. The TypeACollection has an Editor attribute of...
7
by: colin | last post by:
Hi, I have my property editor wich uses the pop up collection editor for arrays etc, but i have had to use a generic wrapper for the elements in some types of collections. although the editing...
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:
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...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.