Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-21
6
Medium Priority
?
856 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
[X]
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
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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Suggested Courses

715 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