Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Combo boxes with 'draggable' icons
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Combo boxes with 'draggable' icons

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


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Topic: Combo boxes with 'draggable' icons
    Posted: 04 February 2008 at 9:51pm
I want to do the ff, using CommandBars :

1). Display a dropdown list combobox in a toolbar
2). Display an image (icon) and text in the items displayed in the combo box
3). Have the items in the combo box sorted alphabetically (by text)
4). Be able to select and 'drag' an item from the combo box list onto a form (for example) and be able to recognize the item that was dragged onto the form - note, dragging an item from the list should not remove it from the list, i.e. the list should remain unchanged after a user selects an item by 'dragging' it from the combobox and 'dropping' it on a form

I wonder if it is possible to do this using command bars ?

I realize that there are quite a lot of steps there, and maybe one person may not have all the answers, but if anyone feels they know the answers to any  (or all) of the steps, I will be very grateful to see how I can code this using teh CommandBar activeX control (I am using VB6)
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 February 2008 at 1:10am
Hi,
Unfortuantelly Combo doesn't support drag. :-(
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 February 2008 at 2:00am
Neil,
 
You could add a CommandBarControlCustom (in your case a combobox) to your commandbar and set the handle to your own combobox which does support drag&drop.
 
An other option would be adding a ControlSplitButtonPopup to your commandbar. Add the items you want with text and icon. This option isn't that different when using a combox, you have a dropdown section just like the combobox and CommandBars seem to support drag&drop so this should do the trick
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 7:37am
Hi Aaron,

Sorry to bother you again, but could you please post a few lines of code to show how I may do this (I prefer the second option - using ControlSplitButtonPopup). I am quite new to the CommandBar controls, and the object heirarchy is proving to be a bit of a 'forest' to navigate through quickly without samploe snippets.

Thanks
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 8:09am
I did a quick search for 'ControlSplitButtonPopup' in the documentation - no items were found. I tried various combinations of the term, but still found nothing. Is this the correct spelling of the object?
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 8:15am
ok, found it as 'xtpControlSplitButtonPopup'

I'm now looking to see if I can create an example, using this button type, and put in a toolbar - if you could send a few lines that show how to do this, I'd be very grateful.

Thanks

Neil
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 February 2008 at 9:23am

Neil,

Delete the Update event I previously sent you. And replace the Execute event with this new one.
 

Const ID_TOOLBAR_COMBO = 1000 '' this is the ID for the SplitButton

Private Function LoadToolbars()
    AddButton CommandBars(1).Controls, xtpControlSplitButtonPopup, ID_TOOLBAR_COMBO, "Select item...", True, "Some text...."
End Function


Private Function AddButton(Controls As CommandBarControls, ControlType As XTPControlType, Id As Long, Caption As String, Optional BeginGroup As Boolean = False, Optional DescriptionText As String = "", Optional ButtonStyle As XTPButtonStyle = xtpButtonAutomatic, Optional Category As String = "Controls") As CommandBarControl
   
    Dim Control As CommandBarControl
    Set Control = Controls.Add(ControlType, Id, Caption)
   
        Control.BeginGroup = BeginGroup
        Control.DescriptionText = DescriptionText
        Control.Style = ButtonStyle
        Control.Category = Category
        Set AddButton = Control
   
End Function


Private Sub CommandBars_InitCommandsPopup(ByVal CommandBar As XtremeCommandBars.ICommandBar)
       
        Select Case CommandBar.BarID
        Case 0
            CommandBar.Controls.DeleteAll
            CommandBar.SetIconSize 16, 16 ''(or whatever iconsize you need)
           
    Dim i As Integer
        Dim selectionControl As CommandBarButton
           
            For i = 1 To 20
                Set selectionControl = CommandBar.Controls.Add(xtpControlButton, i, "Item " & i)
                    selectionControl.CloseSubMenuOnClick = True ''False won't hide the dropdown section when clicked
                    selectionControl.DefaultItem = True ''Text will be bold (maybe for previous selected items)
                    selectionControl.Enabled = True ''
                    selectionControl.Style = xtpButtonIconAndCaption
                   
        If i Mod 10 = 1 Then
                    selectionControl.Flags = xtpFlagWrapRow ''every 10 items to the next column
                End If
            Next i
        End Select
   
End Sub


Private Sub CommandBars_Execute(ByVal Control As XtremeCommandBars.ICommandBarControl)
   
        Select Case Control.Id
            Case 1 To 20
                Dim controlSelect As CommandBarButton
                Set controlSelect = CommandBars.FindControl(, ID_TOOLBAR_COMBO)
                    controlSelect.Caption = Control.Caption
               
    End Select
   
End Sub
Private Sub Form_Load()
        LoadToolbars
End Sub

Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 9:36am
Hi Aaron,

In case you are struggling to provide an example that shows how to do what I wanted to do (thanks for the last snippet by the way - great help), please post the last message I sent to you, in here, so that maybe someone else may take a look at it if you are not quite sure how to solve it - I accidentally posted it to you as a private message, and I can't retrieve the text I sent.

Thanks

Neil
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2008 at 10:20am
Oleg,

Does any other 'list of items' control (that can be displayed in a toolbar) support drag?
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 February 2008 at 12:09pm
Neil,
 
Here's the post as you asked me to add to the original post
 
Aaron,
 
This is what I'm trying to do. I have a rather long list that I want to display in a combo box in a toolbox. thanks to the code you sent me, I now know how to place the combo box in a toolbar, and how to add images to the toolbar.

There are two other things that I still need to find out how to do:

1). Restrict the number of items of items on display, at any one time. I will have potentially, over 100 items to display in the combo box, but I want to be able to limit that to a reasonable number (say 10). Ideally, I would like to make it possible for the user to type in the first
character, and then simply show items begining with that character. I could have sworn that I saw a CommandBar example somewhere that shows how to filter items in a dropdown list as a user is typing - but for the lif e of me, I cannot find that anywhere - and I've searched EVERYWHERE. If I can find out how to do this (or similar), that would be absolutely fantastic - since showing over 100 items in a menu is not really practical.

2). Implementing 'drag drop, so that a user can select an item from the list, drag it and drop it on (say) a form.

Thanks very much for takling the time out to help me out.

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 February 2008 at 1:16pm

Neil, actually galleries support drag.

If you have last CommandBars, try this sample:
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.184 seconds.