Click here to Skip to main content
14,920,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have extended a combo box to over ride the OnSelectedIndexChanged event. The control works as intended. When the form that the control has been placed on is opened, the control displays. After running the application in debug mode and looking at the form (that was open when debugging started) the control is not visible. It is still there, just not visible. If the form is closed and opened again, the control is then visible.

Here is an example of my extended combo box:
using System;
using System.ComponentModel;

namespace CustomControls
    public partial class ComboBoxSN : ComboBox
        private bool _haltSelection = false;

        /// <summary>
        /// Set whether to run the selectedindex event for the control
        /// </summary>
        [Description("Set this to true to keep the selected index from firing"), Category("CustomControl"), DefaultValue(false), Browsable(true)]
        public bool HaltSelection
            get { return _haltSelection; }
            set { _haltSelection = value; }

        protected override void OnSelectedIndexChanged(EventArgs e)
            if (!_haltSelection)

What I have tried:

I have searched CodeProject with out any success.
What is needed so the control always shows in the designer?
Thank you.
Updated 27-Apr-20 8:36am

1 solution

This can be a bit tricky. It is really related to Visual Studio and there are surely differences in the various versions.
I've struggled with this in the past also and it can drive you crazy.
Method 1
Anyways, the easiest way that will probably work is to
1. open your target project
2. open the form where you want to use the control. (if you don't open a form then the toolbox item in Visual Studio doesn't normally appear)
3. open your Toolbox (the place where you choose controls that you'll drag and drop onto a form).
4. Have you ever noticed these are grouped into collapsible tabs? well, go to the tab that says general...and go below it and right-click and a menu will appear that looks something like this -->[^]
5. you want to select the [Choose items...] menu item.
When you select that then another dialog box will appear.
This is where you will choose the control that you want Visual Studio to know about.
6. click the browse button and browse to the location where you have the dll that contains the control and select it.

This will add it to the General list and will register it with VStudio and _probably_ solve the problem.

Method 2
If you have a UserControl defined within your project you will have something like I have with a TextArea.cs (mine is a special textbox).
If you have that, then
1. go under Solution Explorer
2. navigate to your file (mine's TextArea.cs) and drag it over to the General tab and drop it on the Toolbox General tab.
3. This will create a reference to the control and register it so Visual Studio will know how to render it.

Either or both of these may require a VSTudio restart.
Good luck.
Member 14116411 27-Apr-20 14:56pm
The issue is not with the control showing up in the Toolbox. It is visible on the form when the form is first opened. The after running the application in debug mode, and exiting out of debug, the control is not visible on the form. (that is if the form was open in the designer when the debug session was started).
raddevus 27-Apr-20 16:40pm
I understood that, but I've seen this occur when the control isn't properly "registered" to Visual Studio. I have had the problem in the past and adding it into the Toolbox has resolved it for me in the designer.
The process of doing that somehow "registers" the control and Visual Studio can render the control. Did you try it? Did you restart VSTudio? Did it not work?
Member 14116411 27-Apr-20 18:01pm
The extended control shows up in the Toolbox. I followed your instructions for Method 1. Before restarting VS there where two extended controls in the Toolbox. After the restart it only showed one. Tested the form and the issue persist.
Attempted Method 2. The control would not show up in the General tab of the Toolbox. Restarted VS and tested the form, issue persist.
Thank you for your help.
Attempted both methods and the issue persist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900