loops - C# Find visible button by tag name and perform click (Compact Framework) -
i developing application windowsce device. within application have 5 panels, in 1 of them visible @ time.
each panel has many different components, however, 1 of many components button has unique tag property set btnok
.
keeping in mind each panel has 1 of unique buttons, , each of buttons has different function:
how can "enter" keypress event find visible ok button , perform click?
try creating function:
private control findcontrol(control parent, string ctlname) { foreach(control ctl in parent.controls) { if(ctl.name.equals(ctlname)) { return ctl; } findcontrol(ctl, ctlname); } return null; }
use function this:
control ctl = findcontrol(this, "btnok"); if (ctl != null) { btnok_click(this, new buttoneventargs()); }
this assumes button click event looks this...
button1_click(object sender, buttoneventargs e) { }
Comments
Post a Comment