how to get previous control in c#
there is a method to GetNextControl
but there is no method to get previous contro开发者_运维百科l
can any body tell me how could i get this
thanx in advance
GetNextControl(Control control, bool forward)
you can specify if you want to get the control forward or backward. For instance to get the backward control of button1
, you can do:
Control previous = GetNextControl(button1, false);//false indicates backward
GetNextControl() will return the previous control if you pass false
in its second argument:
Control prev = yourControl.GetNextControl(origin, false);
I agree the method name is somewhat confusing, but you're arguably indeed looking for the next control, only in the other direction.
Yes, you can use it like:
var control = GetNextControl(origControl, false);
精彩评论