[dba-VS] Using RemoveHandler in a Combobox Base Class

Dan Waters df.waters at outlook.com
Tue Jun 9 12:24:46 CDT 2015


Hi Shamil,

Thanks for your code!  I translated to VB and I'm using VS 2013.

In my class for a custom control, InitializeComponent() would not convert.  I do have MyBase.New() in the Sub New procedure for each control.

I have moved my code MyBase.OnEnter(e) from the last line in the procedure to the first line.

I set up a test form with a custom textbox and custom combobox.  When I tabbed into the combobox the SelectedIndexChanged event did NOT fire.  However, when I set a breakpoint or a Stop command in the OnEnter procedure in the custom combobox class, the SelectedIndexChanged event in the combobox control in my test form DID fire.  Removing the breakpoint and Stop command resulted in the SelectedIndexChanged event NOT firing.

I got the same results in my other forms as well.

So, I don't know if this rises to the level of a bug, but there is an easy solution - stop debugging in the custom control (but it's a lousy solution).

Thanks for your help!
Dan

-----Original Message-----
From: dba-VS [mailto:dba-vs-bounces at databaseadvisors.com] On Behalf Of Salakhetdinov Shamil
Sent: Saturday, June 06, 2015 9:47 AM
To: Development in Visual Studio
Subject: Re: [dba-VS] Using RemoveHandler in a Combobox Base Class

 Hi Dan --

I have checked with VS2012 and C#:

using System;
namespace WindowsForms.TestApp
{
public partial class MyDropDownUserControl1 : System.Windows.Forms.ComboBox { public MyDropDownUserControl1() { InitializeComponent(); } protected override void OnEnter(EventArgs e) { base.OnEnter(e);
 if (this.SelectedIndex == -1) this.DroppedDown = true; } } }

it doesn't fire SelectedIndexChanged event.

Thank you.

-- Shamil





More information about the dba-VS mailing list