110,533
社区成员
发帖
与我相关
我的任务
分享
bool bStatus = true;
private void FocusHasPicNode(TreeListNodes nodes)
{
if(!bStatus)
return;
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in nodes)
{
string sIsRead = (node.GetValue("A") != null) ? node.GetValue("A").ToString() : string.Empty;
string sPicKind = (node.GetValue("B") != null) ? node.GetValue("B").ToString() : string.Empty;
if ((!string.IsNullOrEmpty(sIsRead)) && (sIsRead.Equals("1")) && (!string.IsNullOrEmpty(sPicKind)) && (!sPicKind.StartsWith("a")) && (!sPicKind.StartsWith("b")) && (node.Visible))
{
//进入这个条件就退出循环,我用return和break都无法直接退出,方法还是会继续运行下去
this.treeList1.FocusedNode = node;
bStatus = false;
}
else
{
if (node.Nodes.Count > 0)
{
FocusHasPicNode(node.Nodes);
}
}
}
}
//你把方法体改成有返回值的 在调用FocusHasPicNode()这方法那里为treeList1.FocusedNode赋值
//如treeList1.FocusedNode=FocusHasPicNode(node);
private DevExpress.XtraTreeList.Nodes.TreeListNode FocusHasPicNode(TreeListNodes nodes)
{
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in nodes)
{
string sIsRead = (node.GetValue("A") != null) ? node.GetValue("A").ToString() : string.Empty;
string sPicKind = (node.GetValue("B") != null) ? node.GetValue("B").ToString() : string.Empty;
if ((!string.IsNullOrEmpty(sIsRead)) && (sIsRead.Equals("1")) && (!string.IsNullOrEmpty(sPicKind)) && (!sPicKind.StartsWith("a")) && (!sPicKind.StartsWith("b")) && (node.Visible))
{
//进入这个条件就退出循环,我用return和break都无法直接退出,方法还是会继续运行下去
//this.treeList1.FocusedNode = node;
return node;
}
else
{
if (node.Nodes.Count > 0)
{
FocusHasPicNode(node.Nodes);
}
}
}
}
int i=0;
while(true)
{
//dosomething
if(i++ == 100)
break;
}
private void FocusHasPicNode(TreeListNodes nodes)
{
foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in nodes)
{
string sIsRead = (node.GetValue("A") != null) ? node.GetValue("A").ToString() : string.Empty;
string sPicKind = (node.GetValue("B") != null) ? node.GetValue("B").ToString() : string.Empty;
if (!(!string.IsNullOrEmpty(sIsRead)) && !(sIsRead.Equals("1")) && !(!string.IsNullOrEmpty(sPicKind)) && !(!sPicKind.StartsWith("a")) && !(!sPicKind.StartsWith("b")) && !(node.Visible))
{
//进入这个条件就退出循环,我用return和break都无法直接退出,方法还是会继续运行下去
//this.treeList1.FocusedNode = node;
if (node.Nodes.Count > 0)
{
FocusHasPicNode(node.Nodes);
}
}
}
}