c# - How can you get a ComboBox child of a DataGridView to process all keys, including "."? -
i have same problem described in posts listed below. is, keys don't work @ when type them combobox until first hit spacebar. 1 of keys ".", letter "q", , there others: "$", "%".
http://forums.microsoft.com/msdn/showpost.aspx?postid=659716&siteid=1
http://forums.microsoft.com/msdn/showpost.aspx?postid=2909173&siteid=1&pageid=0
http://bytes.com/forum/thread548399.html
i've tried lot of things far. latest failure based on theory maybe datagridview using win32 api wndproc subclassing intercept messages, wrote logic save old wndproc , restore after adding datagridview's control collection. didn't work.
messina - reminding me spy++. letter "a", edit window sends en_update combobox parent. but, not "q". that's strange.
i have convinced myself datagridview not subclassing combo , edit, because check address of wndprocs after creation , before adding them grid's collection, , later when paint. unless grid installs sort of global hooks..
i'm thinkin, maybe can subclass edit control, , send notification combobox way see edit control doing here?
edit: more info here. windows messages grid, combobox, , edit control, spy++:
hwnds: 122064e < grid 010d0674 < combobox 01360696 < combox's edit control
<01402> 01360696 p wm_keydown nvirtkey:'a' crepeat:1 scancode:1e fextended:0 faltdown:0 frepeat:0 fup:0 <01403> 010d0674 s wm_getdlgcode <01404> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01405> 010d0674 s wm_getdlgcode <01406> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01407> 010d0674 s wm_getdlgcode <01408> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01409> 010d0674 s wm_getdlgcode <01410> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01411> 01360696 p wm_char chcharcode:'0061' (97) crepeat:1 scancode:1e fextended:0 faltdown:0 frepeat:0 fup:0 <01412> 010d0674 s wm_getdlgcode <01413> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01414> 010d0674 s wm_getdlgcode <01415> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01416> 010d0674 s wm_command wnotifycode:en_update wid:1001 hwndctl:01360696 <<< edit control sends combobox <01417> 010d0674 s message:0x2111 [user-defined:wm_user+7441] wparam:00060674 lparam:010d0674 these do? <01418> 010d0674 r message:0x2111 [user-defined:wm_user+7441] lresult:00000000 <01419> 010d0674 r wm_command <01420> 010d0674 s wm_ctlcoloredit hdcedit:c7011aa6 hwndedit:01360696 <01421> 010d0674 r wm_ctlcoloredit hbrush:f0103eb0 <01422> 010d0674 s wm_command wnotifycode:en_change wid:1001 hwndctl:01360696 << edit control sends combobox <01423> 010d0674 s message:0x2111 [user-defined:wm_user+7441] wparam:00050674 lparam:010d0674 <01424> 0122064e s wm_paint hdc:00000000 <<< grid told paint <01425> 0122064e s wm_erasebkgnd hdc:94011d4e <01426> 0122064e r wm_erasebkgnd ferased:true <01427> 0122064e s wm_gettextlength <01428> 0122064e r wm_gettextlength cch:0 <01429> 0122064e s wm_gettext cchtextmax:2 lpsztext:0012d0c0 <01430> 0122064e r wm_gettext cchcopied:0 lpsztext:0012d0c0 ("") <01431> 0122064e s wm_gettextlength <01432> 0122064e r wm_gettextlength cch:0 <01433> 0122064e s wm_gettext cchtextmax:2 lpsztext:0012d0c0 <01434> 0122064e r wm_gettext cchcopied:0 lpsztext:0012d0c0 ("") <01435> 010d0674 s wm_windowposchanging lpwp:0012d4b0 <01436> 010d0674 r wm_windowposchanging <01437> 010d0674 s cb_getcursel <01438> 010d0674 r cb_getcursel index:cb_err <01439> 010d0674 s wm_gettextlength <01440> 01360696 s wm_gettextlength <01441> 01360696 r wm_gettextlength cch:2 <01442> 010d0674 r wm_gettextlength cch:2 <01443> 010d0674 s wm_gettext cchtextmax:6 lpsztext:0012cc44 <01444> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012be64 <01445> 01360696 r wm_gettext cchcopied:2 lpsztext:0012be64 ("a") <01446> 010d0674 r wm_gettext cchcopied:2 lpsztext:0012cc44 ("a") <01447> 010d0674 s cb_getcursel <01448> 010d0674 r cb_getcursel index:cb_err <01449> 010d0674 s wm_gettextlength <01450> 01360696 s wm_gettextlength <01451> 01360696 r wm_gettextlength cch:2 <01452> 010d0674 r wm_gettextlength cch:2 <01453> 010d0674 s wm_gettext cchtextmax:6 lpsztext:0012cc44 <01454> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012be64 <01455> 01360696 r wm_gettext cchcopied:2 lpsztext:0012be64 ("a") <01456> 010d0674 r wm_gettext cchcopied:2 lpsztext:0012cc44 ("a") <01457> 010d0674 s cb_getcursel <01458> 010d0674 r cb_getcursel index:cb_err <01531> 0122064e r wm_paint <01532> 010d0674 s wm_paint hdc:00000000 <01533> 010d0674 s wm_ncpaint hrgn:00000001 <01534> 010d0674 r wm_ncpaint <01535> 010d0674 s wm_erasebkgnd hdc:0f0141ed <01536> 010d0674 r wm_erasebkgnd ferased:true <01537> 0122064e s wm_ctlcoloredit hdcedit:840137f1 hwndedit:010d0674 <01538> 0122064e r wm_ctlcoloredit hbrush:f0103eb0 <01539> 010d0674 r wm_paint <01540> 01360696 s wm_paint hdc:00000000 <01541> 01360696 s wm_ncpaint hrgn:00000001 <01542> 01360696 r wm_ncpaint <01543> 01360696 s wm_erasebkgnd hdc:c7011aa6 <01544> 01360696 r wm_erasebkgnd ferased:true <01545> 010d0674 s wm_ctlcoloredit hdcedit:870137f1 hwndedit:01360696 <01546> 010d0674 r wm_ctlcoloredit hbrush:f0103eb0 <01547> 010d0674 s wm_ctlcoloredit hdcedit:870137f1 hwndedit:01360696 <01548> 010d0674 r wm_ctlcoloredit hbrush:f0103eb0 <01549> 01360696 r wm_paint <01555> 0122064e s wm_ctlcoloredit hdcedit:8a0137f1 hwndedit:010306ac <01556> 0122064e r wm_ctlcoloredit hbrush:78103c5b <01568> 010d0674 s cb_getcursel <01569> 010d0674 r cb_getcursel index:cb_err <01570> 010d0674 s wm_gettextlength <01571> 01360696 s wm_gettextlength <01572> 01360696 r wm_gettextlength cch:2 <01573> 010d0674 r wm_gettextlength cch:2 <01574> 010d0674 s wm_gettext cchtextmax:6 lpsztext:0012d7a4 <01575> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012c9c4 <01576> 01360696 r wm_gettext cchcopied:2 lpsztext:0012c9c4 ("a") <01577> 010d0674 r wm_gettext cchcopied:2 lpsztext:0012d7a4 ("a") <01578> 010d0674 s cb_getcursel <01579> 010d0674 r cb_getcursel index:cb_err <01580> 010d0674 s wm_gettextlength <01581> 01360696 s wm_gettextlength <01582> 01360696 r wm_gettextlength cch:2 <01583> 010d0674 r wm_gettextlength cch:2 <01584> 010d0674 s wm_gettext cchtextmax:6 lpsztext:0012d6e0 <01585> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012c900 <01586> 01360696 r wm_gettext cchcopied:2 lpsztext:0012c900 ("a") <01587> 010d0674 r wm_gettext cchcopied:2 lpsztext:0012d6e0 ("a") <01588> 010d0674 s cb_getcursel <01589> 010d0674 r cb_getcursel index:cb_err <01590> 010d0674 s wm_gettextlength <01591> 01360696 s wm_gettextlength <01592> 01360696 r wm_gettextlength cch:2 <01593> 010d0674 r wm_gettextlength cch:2 <01594> 010d0674 s wm_gettext cchtextmax:6 lpsztext:0012d6e0 <01595> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012c900 <01596> 01360696 r wm_gettext cchcopied:2 lpsztext:0012c900 ("a") <01597> 010d0674 r wm_gettext cchcopied:2 lpsztext:0012d6e0 ("a") <01598> 010d0674 r message:0x2111 [user-defined:wm_user+7441] lresult:00000000 <01599> 01360696 s wm_gettextlength <01600> 01360696 r wm_gettextlength cch:2 <01601> 01360696 s wm_gettext cchtextmax:6 lpsztext:0012df8c <01602> 01360696 r wm_gettext cchcopied:2 lpsztext:0012df8c ("a") <01603> 010d0674 r wm_command <01604> 01360696 p wm_keyup nvirtkey:'a' crepeat:1 scancode:1e fextended:0 faltdown:0 frepeat:1 fup:1
letter q
<01625> 01360696 p wm_keydown nvirtkey:'q' crepeat:1 scancode:10 fextended:0 faltdown:0 frepeat:0 fup:0 <01626> 010d0674 s wm_getdlgcode <01627> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01628> 010d0674 s wm_getdlgcode <01629> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01630> 010d0674 s wm_getdlgcode <01631> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01632> 010d0674 s wm_getdlgcode <01633> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01634> 01360696 p wm_char chcharcode:'0071' (113) crepeat:1 scancode:10 fextended:0 faltdown:0 frepeat:0 fup:0 <01635> 010d0674 s wm_getdlgcode <01636> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01637> 010d0674 s wm_getdlgcode <01638> 010d0674 r wm_getdlgcode fudlgcode:dlgc_wantarrows | dlgc_wantchars <01640> 01360696 p wm_keyup nvirtkey:'q' crepeat:1 scancode:10 fextended:0 faltdown:0 frepeat:1 fup:1
by chance, have solved problem?
i have same problem yours, custom control datagridview cannot receive letter q, period, dollar, single quote, percent, etc.
i able solve problem changing "switch .. default: return false" "switch .. default: return !datagridviewwantsinputkey"
i guess pattern code microsoft making own usercontrol datagridview not optimal. pattern code microsoft:
http://msdn.microsoft.com/en-au/library/7tas5c80(vs.80).aspx
public bool editingcontrolwantsinputkey( keys key, bool datagridviewwantsinputkey) { // let datetimepicker handle keys listed. switch (key & keys.keycode) { case keys.left: case keys.up: case keys.down: case keys.right: case keys.home: case keys.end: case keys.pagedown: case keys.pageup: return true; default: return false; // changed to: return !datagridviewwantsinputkey. usercontrol can receive q, period, dollar, etc. } }
Comments
Post a Comment