Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Property Grid
  New Posts New Posts RSS Feed - Bug In Begin Update!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Bug In Begin Update!

 Post Reply Post Reply
Author
Message
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Topic: Bug In Begin Update!
    Posted: 23 December 2005 at 10:02am

Hi Codejock guys!

Here a christmas bug for you!!!

Beginupdate\EndUpdate methods are bugfull. Propertygrid doesn't save at all status (item selected, sorting, item expanded etc. ) of the property grid!!!

I have a propertygrid and i want update this propertygrid. According to the documentation, the BeginUpdate\EndUpdate let me save the status (item selected, sorting, item expanded etc. ) of the property grid inside a PropertyGridUpdateContext object, then i can update the propertygrid and at last i call endupdate to restore the status of propertygrid.

Well, it doesn't work at all!!!

Look at the sample in attachment, here i have a simple form with a propertygrid and a button. In the form_load i load the propertygrid with a category (mycategory) and an item (myitem). Pressing the command button i call code to add some category and item to property grid, this code is inside a beginupdate\endupdate.

Ok now try the code, at first you can see the property filled with MyCategory and MyItem. But when you press the command button the propertygrid clear MyCategory and MyItem and and add all the others category.

So propertygrid doesn't save at all status (item selected, sorting, item expanded etc. ) of the property grid!!!

What's appened ???

Thank you in advance.

2005-12-23_100202_CodejockBeginUpdateBug.zip

 

 

SuperPippo
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 December 2005 at 2:14am

 

Unfortunatelly it is not bug

The secret of Beginupdate\EndUpdate methods that they store _ID_ of items was selected/expanded and set selection/expand state  to item with same _ID_ after EndUpdate call:

Here fix:

        Dim iCategory As Integer, iItem As Integer, iID As Integer

        For iCategory = 0 To 2
             Set Category = wndPropertyGrid.AddCategory("Category " & iCategory)
            iID = iID + 1
             Category.Id = iID
 
          
             For iItem = 0 To 2
                 Set Item = Category.AddChildItem(PropertyItemBool, "Item " & iItem, True)
                  iID = iID + 1
                 Item.Id = iID
             Next
        Next

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 28 December 2005 at 3:56am

Dear Oleg,

thank you for the answer.

Have you tested your code ?

I put it on my sample, but still doesn't work at all !!!!

Here is my sample code with your workaround....

2005-12-28_035237_codejockBeginUpdate.zip

so you can see it doesn't work!!!!

May be that it is really a bug, please let me know.

Waiting for your answer, good year to all codejock staff.

P.S. I am using 9.60.1 release of propertygrid.

 

SuperPippo
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 December 2005 at 1:55am

Yes, I have tested it, but you didn't copy it.

You forgot first line

Dim iCategory As Integer, iItem As Integer, iID As Integer

and delete "Private iID As Integer"

 

See result: 2005-12-30_015534_codejockBeginUpdate.zip

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 30 December 2005 at 3:52am

I don' t forget nothing. You can find the line as the first line in the code as follow:

Private iID As Integer

If you look better the code you can understand why i did so: the reason is that in the form load i start the population of propertygrid, so I save on iID the counter of items.

When the user press the command button i add some categories and items on propertygrid, and i use iID to give correct .id property to everyone.

But when i do so all the previous population of category and item are destroyed!

Now I have understand that may be this is not a bug but a serious limit of beginupdate\endupdate implementation, since the PropertyGridUpdateContext object doesn't save an image of the population but just an image of properties of the items in the population. So if you want to update something in propertygrid you MUST rebuild all the grid!!!

This way Beginupdate\Endupdate works fine but it's a really poor implementation!!!

Everyway, thanks a lot Oleg, you are a really kind guy and the next time you came in Italy I will glad to eath a pizza with you !!!!

 

SuperPippo
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 December 2005 at 1:16pm

Hello,

Yes, it is the way how BeginUpdate works - it deletes all items on call.

 

But Everyway, Happy New year :)

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Superpippo View Drop Down
Groupie
Groupie


Joined: 02 March 2005
Status: Offline
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote Superpippo Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2006 at 3:12am

Thank you Oleg.

Happy new year.

SuperPippo
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.152 seconds.