Hi,

I have an application which has two winforms. One is the parent form which
has around 20 odd controls. And the other has a propertygrid and two buttons,
viz OK and Cancel. This form runs in the designerhost. Hence if a property is
changed the componentchanged event fires and changes are seen on the control
on my first form. Is there a way to defer this event such that on click of OK
button the changes are reflected and on click of cancel i get an option to
rollback or revert the changes.

Thanks for all the help.
Regards
Ser

Re: Propertygrid issue by Bryan

Bryan
Fri Mar 02 16:10:11 CST 2007

You need to start a designer transaction when your property grid form
loads. Then, you can either commit the transaction when the user clicks
OK or roll it back to the old values when the user clicks Cancel. This
is how Visual Studio implements undo and redo when you make changes in
the various designers.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com



"ser" <ser@discussions.microsoft.com> wrote in message
news:94F42E2B-4A52-4E92-AEFE-E4F88B52E174@microsoft.com:

> Hi,
>
> I have an application which has two winforms. One is the parent form which
> has around 20 odd controls. And the other has a propertygrid and two buttons,
> viz OK and Cancel. This form runs in the designerhost. Hence if a property is
> changed the componentchanged event fires and changes are seen on the control
> on my first form. Is there a way to defer this event such that on click of OK
> button the changes are reflected and on click of cancel i get an option to
> rollback or revert the changes.
>
> Thanks for all the help.
> Regards
> Ser


Re: Propertygrid issue by ser

ser
Wed Mar 07 08:32:15 CST 2007

Hi Bryan,

Thanks a lot for your reply.
I had tried using DesignerTransaction. But it seems like there is an
internal commit that fires which leaves nothing to rollback or cancel. As i
am using desigherhost, the conponentchanged event seems to fire everytime a
property is changed. Is there a possiblility that this could lead to an
internal commit? If it is, then is there a way to defer componentchanged
event that fires on the propertychange?

Thanks again,
Ser

"Bryan Phillips" wrote:

> You need to start a designer transaction when your property grid form
> loads. Then, you can either commit the transaction when the user clicks
> OK or roll it back to the old values when the user clicks Cancel. This
> is how Visual Studio implements undo and redo when you make changes in
> the various designers.
>
> --
> Bryan Phillips
> MCSD, MCDBA, MCSE
> Blog: http://bphillips76.spaces.live.com
>
>
>
> "ser" <ser@discussions.microsoft.com> wrote in message
> news:94F42E2B-4A52-4E92-AEFE-E4F88B52E174@microsoft.com:
>
> > Hi,
> >
> > I have an application which has two winforms. One is the parent form which
> > has around 20 odd controls. And the other has a propertygrid and two buttons,
> > viz OK and Cancel. This form runs in the designerhost. Hence if a property is
> > changed the componentchanged event fires and changes are seen on the control
> > on my first form. Is there a way to defer this event such that on click of OK
> > button the changes are reflected and on click of cancel i get an option to
> > rollback or revert the changes.
> >
> > Thanks for all the help.
> > Regards
> > Ser
>
>

Re: Propertygrid issue by ser

ser
Wed Mar 07 08:46:12 CST 2007

Hi Bryan,
Following is a part of the call stack. Before executing the code in the
overriden method of Component Changed event:
System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object
component = {label1 [System.Windows.Forms.Label], Text: label1}, object value
= Yes) + 0x196 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValueCore(object
obj = {label1 [System.Windows.Forms.Label], Text: label1}, object value, bool
doUndo) + 0xd4 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.SetPropertyValue(object
obj = {label1 [System.Windows.Forms.Label], Text: label1}, object objVal =
Yes, bool reset, string undoText) + 0x3b8 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.PropertyValue.set(object value) + 0x1e bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyGridView.CommitValue(System.Windows.Forms.PropertyGridInternal.GridEntry
ipeCur =
{System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry
RightToLeft}, object value = Yes) + 0xc7 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyGridView.CommitValue(object value) + 0x4e bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyGridView.DoubleClickRow(int row, bool toggleExpand, int type) + 0x144 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyGridView.OnGridEntryLabelDoubleClick(object s, System.EventArgs e) + 0x4f bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.GridEntry.RaiseEvent(object key, System.EventArgs e) + 0x40 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.GridEntry.OnLabelDoubleClick(System.EventArgs e) + 0x27 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.GridEntry.OnMouseClick(int
x, int y, int count, System.Windows.Forms.MouseButtons button) + 0x105 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.OnMouseClick(int
x, int y, int count, System.Windows.Forms.MouseButtons button) + 0xe4 bytes

System.Windows.Forms.dll!System.Windows.Forms.PropertyGridInternal.PropertyGridView.OnMouseDown(System.Windows.Forms.MouseEventArgs me) + 0x198 bytes

-------------------------------------------------------------------------------

"ser" wrote:

> Hi Bryan,
>
> Thanks a lot for your reply.
> I had tried using DesignerTransaction. But it seems like there is an
> internal commit that fires which leaves nothing to rollback or cancel. As i
> am using desigherhost, the conponentchanged event seems to fire everytime a
> property is changed. Is there a possiblility that this could lead to an
> internal commit? If it is, then is there a way to defer componentchanged
> event that fires on the propertychange?
>
> Thanks again,
> Ser
>
> "Bryan Phillips" wrote:
>
> > You need to start a designer transaction when your property grid form
> > loads. Then, you can either commit the transaction when the user clicks
> > OK or roll it back to the old values when the user clicks Cancel. This
> > is how Visual Studio implements undo and redo when you make changes in
> > the various designers.
> >
> > --
> > Bryan Phillips
> > MCSD, MCDBA, MCSE
> > Blog: http://bphillips76.spaces.live.com
> >
> >
> >
> > "ser" <ser@discussions.microsoft.com> wrote in message
> > news:94F42E2B-4A52-4E92-AEFE-E4F88B52E174@microsoft.com:
> >
> > > Hi,
> > >
> > > I have an application which has two winforms. One is the parent form which
> > > has around 20 odd controls. And the other has a propertygrid and two buttons,
> > > viz OK and Cancel. This form runs in the designerhost. Hence if a property is
> > > changed the componentchanged event fires and changes are seen on the control
> > > on my first form. Is there a way to defer this event such that on click of OK
> > > button the changes are reflected and on click of cancel i get an option to
> > > rollback or revert the changes.
> > >
> > > Thanks for all the help.
> > > Regards
> > > Ser
> >
> >