c# - Invoke FlowLayoutPanel Mousedown handler when clicked child control -


i working in vs 2010, windows form control.

i have extended flowlayoutpanel, in dynamically add buttons

my problem mousedowneventhandler flowlayout planel executes when clicked anywhere except buttons. when clicked on button mousedowneventhandler flowlayoutpanel not called.

i tried wiring function click event handlers of buttons added panel. noticed delays due having issues working ahead.

can me this?

this propably not best approch works me:

//global mouse down handler controls in flow panel private void controlmousedown(object sender, mouseeventargs e) {     var control = (control)sender;      if (control.parent flowlayoutpanel)     {         flowlayoutpanel1_mousedown(sender, e); //if have seperate method handle click on flowpanel otherwise see reflection approach below     } } 

reflection approach:

var onmousedown = flowlayoutpanel1.gettype().getmethod("onmousedown", system.reflection.bindingflags.nonpublic | system.reflection.bindingflags.instance); onmousedown.invoke(flowlayoutpanel1, new object[] { e }); 

you can bind global event child controls in flow panel easly , works okey me. hope helped :)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -