C#: How to suppress UserControl to give focus the first child-control? -


i have usercontrol can have childcontrol.

the usercontrol have styles:

this.setstyle(             controlstyles.allpaintinginwmpaint |             controlstyles.optimizeddoublebuffer |             controlstyles.selectable |             controlstyles.supportstransparentbackcolor |             controlstyles.userpaint,             true);

now if click on usercontrol (not child-control) want usercontrol keep focus, focus automatically goes first child-control. same thing happens if use tab key.

i tried override ongotfocus without success.

any idea?

this hard-coded behavior inside usercontrol class, traps wm_setfocus message , passes focus child control. not know of way override this, trapping in wndproc() doesn't work since there no way uc base class handle it.

the best approach avoid battle , use docked panel control stand-in focusing events want uc handle. requires hacking well, panel container control, can bypassed. check out my answer here focusable panel.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -