forms - Call method from parent inside helper c# -


i trying call method class, inside method, call method first class... can't explain better, here's want code...

myclass.cs

public static void validarcampos(object sender) { **some code here** }  // here, keydown function calls myhelper.cs=>textboxkyedown method private void tb_keydown(object sender, keyeventargs e) {     (sender textbox).textboxkeydown(e, this); } 

myhelper.cs

public static void textboxkeydown(this textbox tb, keyeventargs e, control container) {     switch (e.keycode)     {         case keys.enter:         case keys.add:             tb.zerofill(e);             // want call myclass.cs=>validarcampos(tb);             // here, before moves next tb, because on             // validarcampos(tb) can tell if next tb             // enabled or not, if not call here             // when press enter or add, wont move next tb             // until press twice...             e.suppresskeypress = true;             container.selectnextcontrol(tb, true, true, false, true);             break;         case keys.decimal:             if ((tb.tag string) == "importe")             {                 e.suppresskeypress = true;                 container.selectnextcontrol(tb, true, true, false, true);             }             break;         case keys.subtract:             e.suppresskeypress = true;             container.selectnextcontrol(tb, false, true, false, true);             break;     } } 

really sorry explanation, if need more clues tell me... not paste whole validarcampos code because ~140 lines... check contents of textboxes , determine ones enabled or disabled depending on result...

if helper method varies depending on context, take @ action delagates. pass function in parameter textboxkeydown. i'd expect function like:

void textboxkeydown(this textbox tb, keyeventargs e, control container,                      action<object> callback) {    callback(tb); } 

and called with:

(sender textbox).textboxkeydown(e, this, validarcampos); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -