Solved

How can I fill Columnheads in a Combobox

Posted on 1999-01-27
9
758 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now