Further more, I don't think the TextChanged event is fired by the Insert
method. If so, the event will be fired recursively, untill the stack
overflows. Hence the problem should be other code.
Lion Shi [MSFT]
Microsoft Support Engineer
Get Secure! www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
| From: XXXX@XXXXX.COM (Rob Hindman)
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Subject: comboBox TextChanged event fires twice because Items.Insert()
fires the event too...
| Date: 22 Aug 2003 13:45:38 -0700
| Organization: http://www.yqcomputer.com/
| Lines: 29
| Message-ID: < XXXX@XXXXX.COM >
| NNTP-Posting-Host: 220.127.116.11
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1061585140 13270 127.0.0.1 (22 Aug 2003
| X-Complaints-To: XXXX@XXXXX.COM
| NNTP-Posting-Date: 22 Aug 2003 20:45:40 GMT
| Xref: cpmsftngxa06.phx.gbl
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
| Hi, I have a simple windows form, with two ComboBox controls (and
| several other controls). For both of the comboBox controls,
| For some reason that I can't figure out, when the user pastes text
| into the comboBox, the event fires twice. At first I didn't notice
| this, but once I added error checking, I started seeing my error
| twice. Here some example code:
| private void comboBox_doit_TextChanged(object sender, System.EventArgs
| Does anyone know how to prevent the second event from firing? I have
| tried using BeginUpdate() & EndUpdate() around Items.Insert(), I have
| tried using a simple bool semaphore, I have even tried unregistering
| the event before calling Items.Insert(), and then adding a new event
| handler after it...
| I also can not figure out why this only happens to one of my
| comboBoxes, and not the other one... Hmmm...
| Alas, I am stuck... I would be grateful for any comments, suggestions,
| or advice...
| Many Thanks,