Solved

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

Posted on 2006-11-21
6
846 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

726 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