树视图节点重选
我正在研究紧凑框架 2.0 并使用 c#。 我在树视图节点重新选择方面遇到问题。场景是这样的: 温度0 温度1 温度2 温度3 我在树视图中有一些节点,并使用向上和向下箭头来上下移动节点。 但问题是,一旦我选择一个节点并单击向上箭头,节点就会向上移动 我无法选择该节点正下方的节点。 假设我选择 temp3 并按向上箭头,则该 temp3 将被 temp2 替换。 像这样: 温度0 温度1 温度3 温度2 此后我无法选择 temp2,但可以选择 temp3 和其他节点(无论发生什么)。
我使用此代码作为向上箭头:
int paramPos = this.treeView1.SelectedNode.Index;
if (paramPos > 0)
{
System.Windows.Forms.TreeNode tempNode = this.treeView1.SelectedNode;
this.treeView1.Nodes[paramPos] = this.treeView1.Nodes[paramPos - 1];
this.treeView1.Nodes[paramPos - 1] = tempNode;
this.treeView1.SelectedNode = this.treeView1.Nodes[paramPos - 1];
foreach (System.Windows.Forms.TreeNode tnode in this.treeView1.Nodes)
{
ArgumentNumberInfo ai = (ArgumentNumberInfo)tnode.Tag;
ai.ArgNo = tnode.Index + 1;
}
treeView1.SelectedNode = tempNode;
this.treeView1_AfterSelect(null, null);
}
}
按向上箭头后,节点将向上,但我无法选择下面的节点。 Node0、
node1、
node2
、node3
如果您选择node3并单击向上箭头,node3将上升,node2将下降,但您无法选择node2。 请给我一些线索为什么会发生。 感谢您的宝贵时间。
I'm working on compact framework 2.0 and using c#.
I have problem with treeview node reselection. Scenario is like this :
temp0
temp1
temp2
temp3
I have some node in treeview and using up and down arrow for moving node up and down.
but problem is that once i select a node and clicking up arrow, node is moved up
and I cann't select node just below this node.
Suppose I select temp3 and press up arrow, this temp3 is replaced by temp2.
like this:
temp0
temp1
temp3
temp2
after this I cann't select temp2 but able to select temp3 and other node whatever is up.
I'm using this code for up arrow:
int paramPos = this.treeView1.SelectedNode.Index;
if (paramPos > 0)
{
System.Windows.Forms.TreeNode tempNode = this.treeView1.SelectedNode;
this.treeView1.Nodes[paramPos] = this.treeView1.Nodes[paramPos - 1];
this.treeView1.Nodes[paramPos - 1] = tempNode;
this.treeView1.SelectedNode = this.treeView1.Nodes[paramPos - 1];
foreach (System.Windows.Forms.TreeNode tnode in this.treeView1.Nodes)
{
ArgumentNumberInfo ai = (ArgumentNumberInfo)tnode.Tag;
ai.ArgNo = tnode.Index + 1;
}
treeView1.SelectedNode = tempNode;
this.treeView1_AfterSelect(null, null);
}
}
After pressing up arrow node is going to up but i cann't able to select node below this.
Node0
node1
node2
node3
If you select node3 and click on up arrow node3 will go up and node2 will come down but you cann't select node2.
please give me some clue why is it happening.
Thnx for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Treeview 节点由内部链表维护。我认为您用来交换它们的方法使链接列表变得混乱。这是我引用的代码部分:
尝试以下代码代替上面的代码:
Treeview nodes are maintained by an internal linked list. I think the method that you're using to swap them around is confusing that linked list. Here's the part of the code that I'm referring to:
Try the following in place of the code above: