REQUEST: Reference an inplacebutton? |
Post Reply |
Author | |
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
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.... |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Item property requare index - not Id.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi,
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.... |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
nighthawk
Senior Member Joined: 11 June 2004 Status: Offline Points: 167 |
Post Options
Thanks(0)
|
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 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Thanks.
FindButton added for InplaceButtons.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
yes, maybe :( will check it.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
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.... |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |