Solved

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

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

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

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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

13 Experts available now in Live!

Get 1:1 Help Now