Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hope there can be some help to my problem.

I have a windows form in which all the controls are created dynamically.

However, all the buttons seem to be triggering "Something" before it's .click event, and the "Something" is causing the selectedindexchanged of my comboboxes to fire. I have thoroughly gone through the event handlers declared, and made sure that none of the buttons have SIC pathed as their events.

I have noticed that the normal behaviour for clicking a button with a mouse, is that when a button is clicked on but held down and released in an area outside of the button, the button is not triggered.

Interestingly in my case, the click itself triggers the "Something" even before the pressing is released.

Anyone would be able to advise what is going on with my buttons?

Here is the InteliTrace events which I don't really seem to understand:

Calls for thread <no name=""> (6976)
[System.Threading.ThreadHelper.ThreadStart()]
SESAdminForm.My.MyApplication.Main(String() Args = {String(0)})
[Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine = {unknown})]
System.Windows.Forms.Application.Run(System.Windows.Forms.ApplicationContext context = {unknown})
ThreadContext.RunMessageLoop(int reason = {unknown}, System.Windows.Forms.ApplicationContext context = {unknown})
ThreadContext.RunMessageLoopInner(int reason = {unknown}, System.Windows.Forms.ApplicationContext context = {unknown})
ThreadContext.RunMessageLoopInner(int reason = {unknown}, System.Windows.Forms.ApplicationContext context = {unknown})
System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd = {unknown}, int msg = {unknown}, System.IntPtr wparam = {unknown}, System.IntPtr lparam = {unknown})
ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m = {unknown})
ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Button.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.ButtonBase.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Control.WmMouseDown(ref System.Windows.Forms.Message m = {unknown}, System.Windows.Forms.MouseButtons button = {unknown}, int clicks = {unknown})
System.Windows.Forms.Control.FocusInternal()
System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd = {unknown}, int msg = {unknown}, System.IntPtr wparam = {unknown}, System.IntPtr lparam = {unknown})
ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m = {unknown})
ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Button.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.ButtonBase.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.Control.WmSetFocus(ref System.Windows.Forms.Message m = {unknown})
System.Windows.Forms.ContainerControl.ActivateControlInternal(System.Windows.Forms.Control control = {unknown})
System.Windows.Forms.ContainerControl.ActivateControlInternal(System.Windows.Forms.Control control = {unknown}, bool originator = {unknown})
System.Windows.Forms.ContainerControl.AssignActiveControlInternal(System.Windows.Forms.Control value = {unknown})
System.Windows.Forms.ContainerControl.UpdateFocusedControl()
System.Windows.Forms.ContainerControl.EnterValidation(System.Windows.Forms.Control enterControl = {unknown})
System.Windows.Forms.ContainerControl.ValidateThroughAncestor(System.Windows.Forms.Control ancestorControl = {unknown}, bool preventFocusChangeOnError = {unknown})
System.Windows.Forms.Control.PerformControlValidation(bool bulkValidation = {unknown})
System.Windows.Forms.Control.NotifyValidating()
System.Windows.Forms.ComboBox.OnValidating(System.ComponentModel.CancelEventArgs e = {unknown})
System.Windows.Forms.ComboBox.NotifyAutoComplete()
System.Windows.Forms.ComboBox.NotifyAutoComplete(bool setSelectedIndex = {unknown})
Set System.Windows.Forms.ComboBox.SelectedIndex(int value = {unknown})
System.Windows.Forms.ComboBox.OnSelectedIndexChanged(System.EventArgs e = {unknown})
SESAdminForm.DataEntry.cBox_SelectionChangeCommittedUseItem2(Object sender = {System.Windows.Forms.ComboBox}, System.EventArgs e = {System.EventArgs})
SESAdminForm.DataEntry.DisplayText()

-> There is 2 button-related messages but one seem to happen even before the mousedown event..

Thanks for your time.
Posted

1 solution

Look at the MouseDown event -looks like you have a handler set for it either in the button, or the form itself.
 
Share this answer
 
Comments
guo en 7-Jul-14 4:30am    
Thanks for the advice..

But I was unable to even find the word "Mousedown" or "Mouse" in the entire solution.

However, the form works well before the initial firing of SIC. Means to say, if SIC is ever fired, then the problem starts coming up..
guo en 7-Jul-14 4:53am    
And so i tried change selectedindexchanged to selectionchangecommitted.. and guess what. the problem went away..

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



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