|
-
Mar 14th, 2023, 08:34 PM
#1
Thread Starter
Lively Member
[RESOLVED] how to create a customized combo box
I'm building a VB.Net WinForms application in VS 2017. What I want to do is create a customized combo box, instances of which will be dynamically added to a form by code at run time as needed. The customizations I need are:
1. preset the values of several existing properties (DropDownStyle, Top, Width, Left, etc.) in the constructor
2. create a few new properties, the values of which will be passed to the constructor and set there
3. add a few public methods
4. add custom handling of the OnKeyPress event, to launch custom code when the user presses the Insert or Delete keys.
I know how to do all this with individual combo boxes that have been manually dragged onto the form from the toolbox. But since this application will be creating combo boxes dynamically in code, I'm not sure how to code the above functionality once and then have it automatically apply to each instance. It's unlikely that I will need this functionality elsewhere, so I'm just looking for the simplest most bulletproof way to get the job done in this project.
I'm pretty sure I could do all this with the stock combo box, but am not sure how to hook up my custom code to the OnKeyPress event. I've also considered creating a class or a user control, but am not sure what the best approach is.
Thanks in advance for any suggestions.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|