473,657 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CollectionEdito r 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 CollectionEdito r 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 CollectionEdito r. 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 CollectionEdito r 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 CollectionEdito r'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 CollectionEdito r class for refreshing the display, nor can I see any way of getting access to the CollectionEdito r'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 2215
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*******@disc ussions.microso ft.com> wrote in message
news:ED******** *************** ***********@mic rosoft.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 CollectionEdito r 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 CollectionEdito r. 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 CollectionEdito r 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
CollectionEdito r'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
CollectionEdito r class for refreshing the display, nor can I see any way of
getting access to the CollectionEdito r'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
492
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 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...
0
1357
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 the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in...
0
1331
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 raised?
0
1609
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. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in which elements can be nested to arbitrary depth). The PropertyGrid control opens an...
0
1227
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 editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other Elements (its purpose is to allow the users to generate XML schemas at runtime, in which elements can be...
0
1562
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 one of a series of web controls. The second one opens a collectioneditor which also exposes two properties : "event" and "command". The "event" property is a combobox that is filled with the events of the control that was selected in the...
0
1588
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 strange thing now is that my derived CollectionEditor's SetItems method is called when testing the collection editing within a small test application, but is NOT called when tested from within the SharpDevelop environment. Thus whenever I add...
2
2378
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 of the fields is a collection. I can expand or collapse the collection in the PropertyGrid fine. However,if I open the CollectionEditor associated with the collection, do nothing, and just close it, I get an index out of range error. Note...
0
1140
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 TypeACollectionEditor. This collection editor derives from the framework CollectionEditor, passing TypeACollection in the constructor to indicate which type it deals with. I then have TypeB, which derives from TypeA, but adds specific
7
3802
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 actually works well, and I can set the name ok in the primary property editor, this makes a mess of the type name displayed in the pop up colection editor, is there any way to change this ?
0
8305
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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
7321
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...
0
5632
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
4151
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
2726
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
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
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.