Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do you set the default style for a dynamic ComboBox? vb6

Posted on 2006-11-21
6
843 Views
Last Modified: 2008-01-09
I am dynamically creating several comboboxes and I need them to have a style of 2. However, this cannot be set at runtime. Is there a way to set the style upon creation of the control.

This does NOT work:
Set cbo = Controls.Add("vb.ComboBox", "cbo")
    MsgBox cbo.Name
    cbo.Style = 2
    cbo.Width = 2000
    cbo.Top = Me.Height / 2 - cbo.Height / 2 - 2000
    cbo.Left = Me.Width / 2 - cbo.Width / 2 - 1000
    cbo.Visible = True
   
0
Comment
Question by:Bullfighter
6 Comments
 
LVL 10

Expert Comment

by:Clif
ID: 17988951
0
 
LVL 2

Author Comment

by:Bullfighter
ID: 17989345
Well, there is certainly a lot of information in here, it will take me a bit to see if it answers my question. I do find it a little amusing that there is a combo box that uses the dropdown list style (2), but it is set manually not through this process.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 500 total points
ID: 17990267
It's read-only at run-time, so you have to completely destroy and recreate the window from scratch if you want to approach it that way, which requires some effort.  You may consider just having pre-loaded combos with different styles as part of a control array with an Index of 0, and then load needed ones thereafter from the appropriate styled combo array.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

860 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