开发者

Equality of Form and Form1

I have a collection of MDI forms, where there are different objects (Form1,Form2 etc). Is there any fast way开发者_StackOverflow how to compare whather selected form (using FOR cycle for iterating through form collection) is Form1,Form2..? Thank you!


  foreach(Form f in AllForms)
  {
      if(f is From1)
         return true;
  }


Sounds like a straightforward thing to do, what is the actual problem you are facing?

Have you tried a regular compare?

foreach(Form f in AllForms) {
  if(f == myForm1)
    return true;
}

Use f == myForm1 if you already have a single instance of Form1 named myForm1 that you are comparing against or f is Form1 if you are looking for "any" Form1, without already having one somewhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜