Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub Classing ComboBox Control

Status
Not open for further replies.

asanjue

Programmer
Oct 9, 2000
11
KE
Hi
I would like to create an active x control with ALL the functionality of a VB Combo but with added functionality of being able to autofill. I have the code for doing this with one combo but it is cumbersome putting the code in all the combos that i have. Is there a way of creating a control with the functionality of a combo plus added functionality that i require? Thanks
 
This is actually quite easy.

Start a project and create an active X control; on the form place a typical combobox and then - if you are new to classes, use the VB Class Builder Utility to create the default events and properties for the combobox. You will be deep within many Property Let/Get/Sets; however, this is the long and necessary aspect of control creation. Finally create a WithEvents for the autofill procedure.

The easier method - if OOP is not your idea of a fun way to invest a few hours - is to create a module and within that module code a public procedure; for example:

Public Function AutoCompleteCombo$(Cbo as ComboBox, sText$)

End Function

and place your generic autocomplete routine in there, referencing the combobox as Cbo.Text etc & c

Then from anywhere in your project call the function as:

AutoCompleteCombo MyControl.Name, MyControl.Text

- Nick
 
Thanks for answering. How do i make sure that the default events of the control i create map to those of a combo. I have tried the ActiveX control Interface Wizard but have had some problems with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top