472,378 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 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 2134
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: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.