在C#代码中嵌套了一层循环后,在识别子元素时,父元素同步被识别,试问如何消除父元素的识别,之让其识别循环中的子层。
循环的代码如下:
int count = webBrowser1.Document.Window.Frames.Count;
for (int i = 0; i < count; i++)
{
HtmlDocument tempElement1 = webBrowser1.Document.Window.Frames[i].Document;
tempElement1.MouseOver += TempElement_MouseOver;
tempElement1.MouseLeave += TempElement_MouseLeave;
int count1 = tempElement1.Window.Frames.Count;
for(int j = 0;j < count1; j++)
{
HtmlDocument tempElement2 = tempElement1.Window.Frames[j].Document;
tempElement2.MouseOver += TempElement_MouseOver;
tempElement2.MouseLeave += TempElement_MouseLeave;
}
}
测试时如下,子层和父层都有红框:求解决