Adding controls into a ListView

Reply

Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Adding controls into a ListView

 
0
  #1
Jul 8th, 2004
Greetings.
I have searched high and low for the above topic but to no avail
Is it possible to add a combo box into one of the columns of a listview control?
Please advise.
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 17
Reputation: cypher is an unknown quantity at this point 
Solved Threads: 0
cypher cypher is offline Offline
Newbie Poster

Re: Adding controls into a ListView

 
1
  #2
Jul 8th, 2004
It is possible. Look into the API "SetParent"

You might want to download the API-Guide Network. (Sorry, can't recall the URL off hand)
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Adding controls into a ListView

 
0
  #3
Jul 8th, 2004
Greetings.
Hey, thanks so much for the "direction".
Did a search in google and I guess I've got a rough picture already.
I'll come back with codes when I'm stuck.
Thanks a lot!
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Adding controls into a ListView

 
0
  #4
Jul 8th, 2004
Greetings.
Right, I have came up with a few lines of codes.

I have 6 rows in the listview, and I need to add 1 comboBox to each row at subItem number 2.
At runtime, I could see 1 comboBox at row 1.
I guess all 6 combo boxes are piled up there.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Do Until myRS.EOF = True
  2. Set objItem = listviewEIP.ListItems.Add(, "A" & myRS!com_code, myRS!com_name)
  3. objItem.SubItems(1) = "Something"
  4. objItem.SubItems(3) = "Anything"
  5. myRS.MoveNext
  6. Loop
  7.  
  8. comboID(0).Visible = False
  9. With listviewEIP.ColumnHeaders
  10.  
  11. Load comboID(1)
  12. Call fillCombo(1)
  13. comboID(1).Top = listviewEIP.ListItems.Item(1).Height
  14. comboID(1).Left = .Item(3).Left
  15. comboID(1).Width = .Item(3).Width
  16. comboID(1).Visible = True
  17. SetParent comboID(1).hWnd, listviewEIP.hWnd
  18. comboID(1).ZOrder
  19.  
  20. For i = 2 To 6
  21. Load comboID(i)
  22. fillCombo (i)
  23. comboID(i).Top = listviewEIP.ListItems.Item(i - 1).Height
  24. comboID(i).Left = .Item(3).Left
  25. comboID(i).Width = .Item(3).Width
  26. comboID(i).Visible = True
  27. SetParent comboID(i).hWnd, listviewEIP.hWnd
  28. comboID(i).ZOrder
  29. Next i
  30. End With

How can I solve that? Please help.
Thanks.
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 17
Reputation: cypher is an unknown quantity at this point 
Solved Threads: 0
cypher cypher is offline Offline
Newbie Poster

Re: Adding controls into a ListView

 
0
  #5
Jul 9th, 2004
Well, looks like you have the right idea for the SetParent API. In all honesty, I've never tried adding controls to a list view or anything else that has multiple places to put them (aside from a toolbar, but that's slightly different).

You might try to find a way to address subItem2's handle. Every control in Windows has a control (or atleast has the opportunity to apply for one). If you want to think about it in a very basic concept, imagine everything is a picturebox, except not everything has a Picture property. From there, you can see that everything has a Height, Width, and Handle. Beyond that, the controls just add their own properties as needed.

So if you can find a way to retrieve subItem2's hWnd, then you should be in business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Adding controls into a ListView

 
0
  #6
Jul 11th, 2004
Greetings.
Ok, I got you.
By the way, I could not fully understand wat does hWnd do.
Could you please explain a little if possible?
In addition, I tried using the combo box's Height property but there is an error stating that combo box's height is read-only, n thus I can't use that parameter to do things with it. I'm not modifying the parameter, but I just want that value.
Please advise.
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 200
Reputation: mnemtsas is an unknown quantity at this point 
Solved Threads: 1
mnemtsas's Avatar
mnemtsas mnemtsas is offline Offline
Junior Poster

Re: Adding controls into a ListView

 
0
  #7
Jul 13th, 2004
Originally Posted by red_evolve
Greetings.
Ok, I got you.
By the way, I could not fully understand wat does hWnd do.
Could you please explain a little if possible?
In addition, I tried using the combo box's Height property but there is an error stating that combo box's height is read-only, n thus I can't use that parameter to do things with it. I'm not modifying the parameter, but I just want that value.
Please advise.
Try taking a look at http://www.vbaccelerator.com . He has a whole pile of stuff there about sub classing and so on. In fact I'd be amazed if his freely downloadable enhanced listview didn't already do exactly what you want.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 17
Reputation: cypher is an unknown quantity at this point 
Solved Threads: 0
cypher cypher is offline Offline
Newbie Poster

Re: Adding controls into a ListView

 
0
  #8
Jul 15th, 2004
Originally Posted by red_evolve
Greetings.
Ok, I got you.
By the way, I could not fully understand wat does hWnd do.
Could you please explain a little if possible?
Everything in windows is an object. Whenever an object is created, it is given a handle by which windows (or any other program that has access to that handle) can address that object. Forms and controls both have handles, although not all controls register to receive them. That's basically what the hWnd (Some weird way of saying handle for a Window.
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Adding controls into a ListView

 
0
  #9
Jul 15th, 2004
Greetings.
Thanks for the url, mnemtsas! Can't really get what you meant by this though:-
In fact I'd be amazed if his freely downloadable enhanced listview didn't already do exactly what you want.
Well, I've browsed thru vbaccelerator , I found something about subclassing.
[1] Add a Check Box to the Left Hand Side of a Drop-Down Combo Box (Currently looking into this as I guess the concept is quite similar.)
[2] Detect when a Combo Box Drops Down or Closes Up (This is indeed very confusing for me!)
Cypher, thanks a lot for the explanation! Understood, but now's time to apply the theory (toughest part! ).
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC