Solved

How can I fill Columnheads in a Combobox

Posted on 1999-01-27
9
762 Views
Last Modified: 2013-12-26
I can add Columnheads, but I can't fill the Columnheads with a value.
(VB 6.0, Combobox Microsoft Forms 2.0 Object Library)

Any help would be great!
0
Comment
Question by:Zimmerli
  • 5
  • 4
9 Comments
 

Author Comment

by:Zimmerli
ID: 1490002
Edited text of question
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1490003
Yep, you are right. You can only do that using data binding with a database.
BTW: Forms2 may only be used inside office VBA. See license agreement
0
 

Author Comment

by:Zimmerli
ID: 1490004
-What control do you use, if you want a combobox with a header (not with a data binding with a database)?
-Is it possible to use a listbox instead of a combobox?
-I use ms forms because i want to use 2 columns. are there other controls (comboboxes) which support 2 (or more) columns

btw: for a good solution i would increase the points to 100
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 13

Expert Comment

by:Mirkwood
ID: 1490005
Use the listview control. Put the listview in detailed mode.
The control is located in the Microsoft common control library

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1490006
Take also a look at this code:

Take a look at the following code. It simulates the access dropdown combo.
Add a combobox and a grid control (Project/add components/Microsoft Databound Grid Control) and a timer to a form and use the code below

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_SHOWDROPDOWN = &H14F

Dim m_bWasVisible As Boolean

Private Sub Combo1_DropDown()
    m_bWasVisible = DBGrid1.Visible
    Timer1.Enabled = True
End Sub

Private Sub DBGrid1_Click()
    Combo1.SetFocus
End Sub

Private Sub dbgrid1_LostFocus()
    DBGrid1.Visible = False
End Sub

Private Sub Form_Click()
    If (DBGrid1.Visible) Then
        DBGrid1.Visible = False
    End If
End Sub

Private Sub Form_Load()
    Timer1.Enabled = False
    Timer1.Interval = 50
    DBGrid1.AllowAddNew = False
    DBGrid1.AllowDelete = False
    DBGrid1.AllowUpdate = False
    DBGrid1.EditActive = False
    DBGrid1.Visible = False
End Sub

Private Sub Timer1_Timer()
    Timer1.Enabled = False
    If (m_bWasVisible) Then
        SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, 0, 0
    Else
        DBGrid1.Visible = True
        DBGrid1.SetFocus
    End If

End Sub

0
 

Author Comment

by:Zimmerli
ID: 1490007
Thanks a lot!
now i have just one last problem:
- I want to use a Combobox with 2 columns (I don't need any headers there) - It works fine with the ms forms 2 combobox - but you wrote that i should use it just with VBA. Is there another combobox which supports more then one column?

btw: you have to answer the question - otherwise I can't give you the points if you just add a comment.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
ID: 1490008
See comments below for answers.

Sorry I don't know any other freeware combobox that has multiple columns. Comboboxes are not that easy to write since the use a larger window area than the area of the control itself when they dropdown.
0
 

Author Comment

by:Zimmerli
ID: 1490009
Thanks a lot!
now i have just one last problem:
- I want to use a Combobox with 2 columns (I don't need any headers there) - It works fine with the ms forms 2 combobox - but you wrote that i should use it just with VBA. Is there another combobox which supports more then one column?

btw: you have to answer the question - otherwise I can't give you the points if you just add a comment.
0
 

Author Comment

by:Zimmerli
ID: 1490010
Adjusted points to 100
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question