Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Property Grid
  New Posts New Posts RSS Feed - REQUEST: Reference an inplacebutton?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

REQUEST: Reference an inplacebutton?

 Post Reply Post Reply
Author
Message
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Topic: REQUEST: Reference an inplacebutton?
    Posted: 25 June 2008 at 5:02am
Hi,
 
I have a propertygrid item with an InplaceButton and want to enable/disable the button when Item.value > 0
 
The button shows and functions OK, now I want to disable it...
 
Private Sub wndPropertyGridFiles_SelectionChanged(ByVal Item As XtremePropertyGrid.IPropertyGridItem)
    Select Case Item.Id
        Case ID_PROPGRID_SELECTEDFILES
            'inplaceButton.Enabled = Item.Value > 0 ' THIS WORKS OK, BUT I DON'T WANT TO HAVE ALL MY BUTTONS SEPARATELY DECLARED AS INPLACEBUTTONS
            Item.InplaceButtons.Item(ID_PROPGRID_BUTTONGENERATEDATA).Enabled = Item.Value > 0 'WHY DOESN'T THIS WORK???
    End Select
   
End Sub

 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 09 July 2008 at 12:54pm
Hi,
 
This seems to be a very difficult question...
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 09 July 2008 at 2:45pm
Hi,
Item property requare index - not Id.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 10 July 2008 at 2:58am
Hi,
 
Thanks for reply. Is there another way? Would you recommend that I declare all my buttons as inplacebuttons?
 
Thank you
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 10 July 2008 at 5:37am
Hi,
 
Why you need another way. It was right way :) Just use its Index:
 
Item.InplaceButtons(1).Enabled = Item.Value > 0
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 13 July 2008 at 2:07am
Hi,
 
  1. When dynamically adding buttons you don't know it's index (it could, but I don't want to keep record of what buttons are added and on which location).
  2. If you change the position of the button (when adding the button) you have change the code in all events as well. I do a lot of changes before I'm satisfied how it looks
So using the index will not be the best approach for me.
 
Thanks
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2009 at 7:39am
Hi Oleg,
 
I thought I give another try... Everyone has started a fresh year  so...
 
This test project is to make a point regarding referencing of inplacebuttons by it's index. I would like to see that the ID is used to reference the inplacebutton. With removing a button, I have to know where the button is located
 
Could you please do something about this?
 
Thanks a lot 
 
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
nighthawk View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 June 2004
Status: Offline
Points: 167
Post Options Post Options   Thanks (0) Thanks(0)   Quote nighthawk Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2009 at 1:22pm
The PropertyGridItems and InPlaceButtons are both collections that you can loop through to find the button with the correct ID.  You can use a  function like:

Private Function getInPlaceButton(p_objPG As XtremePropertyGrid.PropertyGrid, p_lngButtonID As Long) As XtremePropertyGrid.PropertyGridInplaceButton
    Dim objItem As XtremePropertyGrid.PropertyGridItem
    Dim objButton As XtremePropertyGrid.PropertyGridInplaceButton
    Dim objFoundButton As XtremePropertyGrid.PropertyGridInplaceButton

    On Error GoTo getInPlaceButton_Error

    'loop through all propertygriditems in propertygrid
    For Each objItem In p_objPG.Categories
        'loop through all inplacebuttons in propertygriditem
        For Each objButton In objItem.InplaceButtons
            'if matching buttonid is found, return inplacebutton and break loops
            If (objButton.Id = p_lngButtonID) Then
                Set objFoundButton = objButton
                Exit For
            End If
        Next
       
        'break category loop if button was found
        If (Not (objFoundButton Is Nothing)) Then
            Exit For
        End If
    Next

    Set objItem = Nothing
    Set objButton = Nothing
    Set getInPlaceButton = objFoundButton

    On Error GoTo 0
    Exit Function

getInPlaceButton_Error:
End Function



This will give you access to the button with the specific ID.  You can then access the Index property to do you delete.  Replace your delete event in your sample project with:

Private Sub Command1_Click()
    wndPropertyGrid.FindItem("Item").InplaceButtons.Remove getInPlaceButton(wndPropertyGrid, 520).index + 1
    wndPropertyGrid.FindItem("Item").Selected = True
End Sub



For some reason, a button reports its own index as 1 off compared to the index of the collection, that is the reason for the "+ 1".  This delete will generate an error if the button id doesn't exist.  You will want to check for that. You can also optimize the getInPlaceButton() code if you already know or have access to the appropriate PropertyGridItem record.
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3
Language: Visual Basic 6.0
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2009 at 4:42pm
Originally posted by nighthawk nighthawk wrote:

[...]
The PropertyGridItems and InPlaceButtons are both collections that you can loop through to find the button with the correct ID. 
[...]
 
Hi Nighthawk,
 
Thanks for reply, I know you can loop through items and buttons. If you don't know the exact item and want to loop the propertygrid items in entire Category and there are multi level items you have to create loop for every child  The reason I did the post and added RETRY to post description is to have Oleg look at the issue again and maybe, just maybe he would add feature to reference button with ID and NOT with Index. It is strange we can loop through collection and retrieve ID, InplaceButton event is also returning ID, the only thing we can't is to reference the button directly  (with ID)
 
Thanks anyway  Now I know I'm not alone waiting for improvement with this...
 
Thank you
 
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 05 January 2009 at 2:19am
Thanks.
FindButton added for InplaceButtons.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 05 January 2009 at 3:55am
Hi Oleg,
 
Thanks a lot  for adding this is next release. Could you please look at my other post and just reply with YES / NO or TODO LIST. If you aren't going to add anything at all just say so... at least I know  
 
 
Thanks again
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2009 at 11:01am
Hi Oleg,
 
The FindButton method is working, thanks for that
 
But I have a remark:
 
The button doesn't get updated with newly assigned value (Caption, icon, etc...) Only when I use it like this:
 
wndPropertyGrid.LockRedraw = True
wndPropertyGrid.FindItem(ID_PROPGRID_PROJECT).InplaceButtons.FindButton(ID_PROPGRID_BUTTON_COPY).IconIndex = ID_PROPGRID_BUTTON_UPDATE   
wndPropertyGrid.LockRedraw = False
 
Without LockRedraw the value gets updated until item is selected / resized (I guess internal redraw).
 
Thanks in advance
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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: 17 February 2009 at 11:33am
yes, maybe :( will check it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2010 at 4:38am
Originally posted by oleg oleg wrote:

yes, maybe :( will check it.
 
 
Hi Oleg,
 
Did you check this? I tried to dynamically add buttons in SelectionChanged event and it doesn't "refresh" only when selecting item a second time. I tried with .LockRedraw as I mentioned in previous reply but that causes a crash. So there's no option to refresh item on first selection :(
 
Note: I tried with V13.1.0 so maybe old version... But I have to ask you if you checked this already before upgrading
 
Thanks
 
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....
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.172 seconds.