///
/// 上移
///
///
///
private
void
tsbmoveup_click(
object
sender, eventargs e)
folder model = new
folder();
treenode node = tv_tree.selectednode; //獲得選中節點的值
model.folderid = node.tag.tostring();
model.theorder = node.name.tostring();
if(node.prevnode ==
null
)
//選中節點的上乙個節點為null則返回
folder upmodel = new
folder();
treenode upnode = node.prevnode; //獲得選中節點的上乙個節點
upmodel.folderid = upnode.tag.tostring();
upmodel.theorder = upnode.name;
bool
flag = folderoperation.moveup(model, upmodel);
//將兩個節點的排序編號互換
if(flag)
//如果執行成功
else
node.remove();
tv_tree.selectednode = newnode;
} else
} ///
/// 下移
///
///
///
private
void
tsbmovedown_click(
object
sender, eventargs e)
folder model = new
folder();
treenode node = tv_tree.selectednode; //選中的節點
model.folderid = node.tag.tostring();
model.theorder = node.name.tostring();
if(node.nextnode ==
null
)
//下乙個節點為null時返回
folder downmodel = new
folder();
treenode downode = node.nextnode;
downmodel.folderid = downode.tag.tostring();
downmodel.theorder = downode.name;
bool
flag = folderoperation.moveup(model, downmodel);
if(flag)
else
downode.remove(); //刪除掉選中節點的下乙個節點
tv_tree.selectednode = node; //重新選中
} else
} string
sql =
string
.format(
"update folder set theorder = '' where folderid = ''"
, model.theorder, upmodel.folderid);
string
sql1 =
string
.format(
"update folder set theorder = '' where folderid = ''"
, upmodel.theorder, model.folderid);
///
/// 節點的展開和摺疊
///
///
///
private
void
tvdocinfo_afterexpand(
object
sender, treevieweventargs e)
} else
} } }
節點拖拽,必須設定treeview的allowdrop屬性為true;
[csharp]view plain
copy
?private
point position =
newpoint(0, 0);
private
void
treeview1_itemdrag(
object
sender, itemdrageventargs e)
private
void
treeview1_dragenter(
object
sender, drageventargs e)
private
void
treeview1_dragdrop(
object
sender, drageventargs e)
else
position.x = e.x;
position.y = e.y;
position = tvtype.pointtoclient(position);
treenode dropnode = this
.tvtype.getnodeat(position);
if(functionsui.createquestiondialog(
"是否要將"
+mynode.text+
"移動"
+dropnode.text+
"類別下?"
) == dialogresult.ok)
// 如果目標節點不存在,即拖拽的位置不存在節點,那麼就將被拖拽節點放在根節點之下
if(dropnode ==
null
)
} }
C TreeView 節點查詢
主窗體部分 遍歷樹節點,並將節點存入list集合中 public void getallnodes treenodecollection nodecollection,listnodelist 查詢 private void b ir click object sender,eventargs e ...
C TreeView 節點查詢
主窗體部分 遍歷樹節點,並將節點存入list集合中 public void getallnodes treenodecollection nodecollection,listnodelist 查詢 private void btnfolder click object sender,eventar...
C 上移,下移TreeView中的樹節點順序
2009 08 12 20 10 1494人閱讀 收藏 舉報 c button object null string c 中,通過單擊上移,下移按鈕移動樹節點中的節點順序的實現方法 c sharp view plain copy public form1 treenode prenode,nextn...