how to get previous control in c#

2019-04-09 15:35发布

how to get previous control in c#

there is a method to GetNextControl but there is no method to get previous control can any body tell me how could i get this

thanx in advance

3条回答
小情绪 Triste *
2楼-- · 2019-04-09 16:22

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
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-04-09 16:26

Yes, you can use it like:

var control = GetNextControl(origControl, false);
查看更多
劳资没心,怎么记你
4楼-- · 2019-04-09 16:38

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.

查看更多
登录 后发表回答