Using controls library to create a custom combobox
-
I created a Windows Controls Library project so that I could create my own modified version of a combobox. When I began the new project VB starts you out with a region to put your controls in. I drop a combobox in there and resized the region to be the same size as the combobox. When I tried using it in a new Windows project the right side of the combo is cut off. If I make that region a little bigger it shows up as being part of the combobox. Can you make this region invisible or keep it from interfering?
-
I created a Windows Controls Library project so that I could create my own modified version of a combobox. When I began the new project VB starts you out with a region to put your controls in. I drop a combobox in there and resized the region to be the same size as the combobox. When I tried using it in a new Windows project the right side of the combo is cut off. If I make that region a little bigger it shows up as being part of the combobox. Can you make this region invisible or keep it from interfering?
Try using the
DockStyle
property of the combobox control. You can either set it in the properties window of your custom control or do it in code (e.g.Combobox1.DockStyle = DockStyle.Top
) -
Try using the
DockStyle
property of the combobox control. You can either set it in the properties window of your custom control or do it in code (e.g.Combobox1.DockStyle = DockStyle.Top
) -
I created a Windows Controls Library project so that I could create my own modified version of a combobox. When I began the new project VB starts you out with a region to put your controls in. I drop a combobox in there and resized the region to be the same size as the combobox. When I tried using it in a new Windows project the right side of the combo is cut off. If I make that region a little bigger it shows up as being part of the combobox. Can you make this region invisible or keep it from interfering?
Something else to consider: if you're only using a single combo box for your control, you should look into inheriting the Windows.Forms.ComboBox. This will solve your display issues. You can get started very easily by pasting this class declaration into a new Class file, overwriting the default text:
Public Class MyCustomCombo Inherits System.Windows.Forms.ComboBox End Class
Mind you, programming an inherited control can be tricky, but the rewards are worth it.james commercial developer, author, speaker, dude. www.jamesfoxall.com
-
Something else to consider: if you're only using a single combo box for your control, you should look into inheriting the Windows.Forms.ComboBox. This will solve your display issues. You can get started very easily by pasting this class declaration into a new Class file, overwriting the default text:
Public Class MyCustomCombo Inherits System.Windows.Forms.ComboBox End Class
Mind you, programming an inherited control can be tricky, but the rewards are worth it.james commercial developer, author, speaker, dude. www.jamesfoxall.com
You read my mind :) but I was thinking it might be a bit too tricky for him considering he's still getting to grips with custom control authoring.
-
Thanks. That worked. But also, while in the designer, if I click on the combobox I frequently cause VB to abnormally shut down. Why does this happen?
I'm not sure, it could be a bug in your copy of VS or perhaps your machine is screwing up somehow, or it may even be (tho I doubt it) your code. Quite honestly, I have no idea.
-
You read my mind :) but I was thinking it might be a bit too tricky for him considering he's still getting to grips with custom control authoring.
I agree, but I wanted to throw it out there. It's certainly worth spending a half hour with google over. :)
james commercial developer, author, speaker, dude. www.jamesfoxall.com