+ Reply to Thread
Results 1 to 11 of 11

Excel: Display combobox as listview subitem

  1. #1
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Excel: Display combobox as listview subitem

    Hello all,

    I am running into some problems trying to implement this:

    I need to have a combobox for user selection as a listview subitem (not the listitem) to enable selection by the user.

    The Listview_MouseUp event only provides x and y coordinates for the click event, but I am stuck trying to figure out how to place a combo box over the relevant subitem (i.e., finding out its exact coordinates).

    I have googled this item a lot and it seems to be possible using subclassing (which I do not know much about), but the best example I've found so far deals with coloring lines, not adding combo boxes:
    http://www.excelforum.com/excel-prog...ored-line.html

    Has anyone had to tackle this before or knows how I could solve it?
    Any help is greatly appreciated.

  2. #2
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    Also, if anyone has a suggestion for a different control than listview, I'd be happy to look into that (would have to be free, though).

  3. #3
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    Has anyone ever done this before?

    I can rephrase the problem now:
    I need a guide for subclassing a VBA listview on a user form to add row background colors and combo-boxes.

    Should I start a new thread with that?

    Still hoping someone out there knows or can point me to a solution.

    Cheers!

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel: Display combobox as listview subitem

    How much data is there and which features of the listview are you actually using?

  5. #5
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    Thanks for replying, Kyle123.
    There will be two listviews in report view, 1 with 3 columns, the other with 10-ish.
    The rows will differ from 10-20 up to as much as several hundred (in extreme cases).

    The functions I need are:
    * row back color
    * combo boxes as/in sub items
    * (would also be great make certain subitems editable (i.e. column-wise, e.g. every subitem in col 10 can take a user comment)
    * and of course, read back the user changes in combos and subitems...

    I haven't had to provide such GUI functionality in Excel/VBA yet, so any hint on how to implement this is greatly appreciated.

    Cheers

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel: Display combobox as listview subitem

    Have a look here http://www.vbforums.com/showthread.p...ide-a-Listview at the attachment that BruceG has uploaded. It's for VB6, but essentially identical for VBA, it's using the standard listview and making it editable by positioning a textbox/combobox.

    A simpler solution would be to have the edit boxes/dropdowns separate in the form and just populate them with data from the listview when clicked

  7. #7
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    Kyle123,

    thank you very much for the pointer. I've tried to import BruceG's file in my VBA project, but couldn't import all.
    I can import the modules into the project, though, but not the forms/project (vbp/vbw)...
    Any chance you can help me with this step, too?
    Sorry and thanks a lot

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel: Display combobox as listview subitem

    You can't import them directly, but you can open them in notepad to see what's going on

    You should be able to copy and paste most of the code then just re-create the relevant controls on the form

    tbh though I'd want a good reason not to go with the alternative of having the edit boxes not in the listview - it's much more simple

  9. #9
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    The reason not to have them separately is the requestor for this form. Wvery click is 1 too many...
    I'll try to work with the sample file.
    One last question: Regarding coloring individual list view rows... that seems not to be possible without subclassing, right?

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel: Display combobox as listview subitem

    Not to be pedantic, but to edit it your way you'd have to click into every control. My way, you'd click the row then can tab between controls, so I reckon my way has fewer clicks

    Trying to make this work will eat your life - it's just not worth doing and will never work perfectly. Either accept that, or accept that there is an easier way, or create your application in a format that allows easier changing of controls - the .Net DataGridView do this out of the box (VB.Net/C#)

    No, it's not
    Last edited by Kyle123; 10-07-2014 at 09:51 AM.

  11. #11
    Registered User
    Join Date
    10-02-2014
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    13

    Re: Excel: Display combobox as listview subitem

    I don't see that as pedantic, Kyle123, and I really appreciate your input, you've helped me a lot.
    I see it the same way, and I'll try to explain that to the requestor as well. (your reasoning with tabbing through controls actually helps bigtime, hadn't considered that).

    I would love to use something else than Excel/VBA as well, but that's out of the question... not my decision.

    Thanks again for your help, I'll do my best to give back to the forum, too

    Edit: I can't get the LVEdit sample to work in VBA. Had to change the Listview_MousUp Handler to the original arguments list since that's different in VBA compared to VB. Then had to add an image to the imagelist in the UserForm_Initialize.
    Now I'm getting the message that I can't pass the x and y arguments 'ByVal'...) Guess I'm giving up on this since as you said, trying to get that to work will be too much effort.

    Thanks again for your help and patience.
    Last edited by ChrisVBA; 10-07-2014 at 10:21 AM. Reason: Added information

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Display multi line text in sub item of a listview .
    By priya06manohar@gmail in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2014, 02:43 PM
  2. [SOLVED] Problem with Listview display in userform
    By Jonno1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2014, 08:10 AM
  3. How to display item in listview
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2014, 01:14 PM
  4. Display data in ListView upon specific text in column Y
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2014, 05:51 PM
  5. Display all files on a specified path on a listbox/listview with icons
    By thisisgerald in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-02-2012, 10:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1