TreeViewWord文件下载.docx

上传人:b****2 文档编号:15155786 上传时间:2022-10-28 格式:DOCX 页数:11 大小:15.90KB
下载 相关 举报
TreeViewWord文件下载.docx_第1页
第1页 / 共11页
TreeViewWord文件下载.docx_第2页
第2页 / 共11页
TreeViewWord文件下载.docx_第3页
第3页 / 共11页
TreeViewWord文件下载.docx_第4页
第4页 / 共11页
TreeViewWord文件下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

TreeViewWord文件下载.docx

《TreeViewWord文件下载.docx》由会员分享,可在线阅读,更多相关《TreeViewWord文件下载.docx(11页珍藏版)》请在冰豆网上搜索。

TreeViewWord文件下载.docx

,"

提示信息"

MessageBoxButtons.OK,MessageBoxIcon.Information);

}

else

//创建一个节点对象,并初始化

try

ArrayListr=newArrayList();

Form3f=newForm3();

f.ShowDialog(this);

TreeNodetmp=newTreeNode(f.textBox1.Text);

r.Add(f.textBox1.Text.ToString());

r.Add(f.textBox2.Text.ToString());

r.Add(f.textBox3.Text.ToString());

r.Add(f.textBox4.Text.ToString());

r.Add(f.textBox5.Text.ToString());

r.Add(f.richTextBox1.Text.ToString());

tmp.Tag=r;

tmp.Text=f.textBox1.Text;

ArrayListt=(ArrayList)this.treeView1.SelectedNode.Tag;

if(System.Convert.ToDateTime(f.textBox2.Text.ToString())<

=System.Convert.ToDateTime(t[1].ToString()))

怎么可能!

"

treeView1.SelectedNode.Nodes.Add(tmp);

treeView1.SelectedNode=tmp;

treeView1.ExpandAll();

catch

正确输入日期!

privatevoidAddParent()

//首先判断是否选定组件中节点的位置

if(treeView1.SelectedNode.Parent==null)

f.ShowDialog();

TreeNodetmp=newTreeNode(f.textBox1.Text);

ArrayListt=(ArrayList)this.treeView1.SelectedNode.Parent.Tag;

if(System.Convert.ToDateTime(f.textBox2.Text)<

MessageBoxButtons.OK,MessageBoxIcon.Information);

treeView1.SelectedNode.Parent.Nodes.Add(tmp);

treeView1.ExpandAll();

//在TreeView组件中加入兄弟节点

遍历接点的算法:

publicTreeNodeFindNode(TreeNoderoot,stringstrValue)

if(root==null)

returnnull;

if(root.Text==strValue)

returnroot;

TreeNoder=null;

foreach(TreeNodenodeinroot.Nodes)

{

r=FindNode(node,strValue);

if(r!

=null)

break;

returnr;

序列化实现对TREEVIEW的存储:

///class2对TreeView进行序列化

///用于文件的存读;

///文件以二进制写入

publicclassTreeViewDataAccess

///TreeViewData

[Serializable()]

publicstructTreeViewData

publicTreeNodeData[]Nodes;

///递归初始化TreeView数据

publicTreeViewData(TreeViewtreeview)

Nodes=newTreeNodeData[treeview.Nodes.Count];

if(treeview.Nodes.Count==0)

return;

for(inti=0;

i<

=treeview.Nodes.Count-1;

i++)

Nodes=newTreeNodeData(treeview.Nodes);

///通过TreeViewData弹出TreeView

publicvoidPopulateTree(TreeViewtreeview)

if(this.Nodes==null||this.Nodes.Length==0)

treeview.BeginUpdate();

=this.Nodes.Length-1;

treeview.Nodes.Add(this.Nodes.ToTreeNode());

treeview.EndUpdate();

///TreeNodeData

publicstructTreeNodeData

publicstringText;

publicintImageIndex;

publicintSelectedImageIndex;

publicboolChecked;

publicboolExpanded;

publicobjectTag;

publicColorBackColor;

///TreeNode构造函数

publicTreeNodeData(TreeNodenode)

this.Text=node.Text;

this.ImageIndex=node.ImageIndex;

this.SelectedImageIndex=node.SelectedImageIndex;

this.Checked=node.Checked;

this.BackColor=node.BackColor;

this.Expanded=node.IsExpanded;

this.Nodes=newTreeNodeData[node.Nodes.Count];

this.Tag=node.Tag;

if(node.Nodes.Count==0)

=node.Nodes.Count-1;

Nodes=newTreeNodeData(node.Nodes);

///TreeNodeData返回TreeNode

publicTreeNodeToTreeNode()

TreeNodeToTreeNode=newTreeNode(this.Text,this.ImageIndex,this.SelectedImageIndex);

ToTreeNode.Checked=this.Checked;

ToTreeNode.BackColor=this.BackColor;

ToTreeNode.Tag=this.Tag;

if(this.Expanded)

ToTreeNode.Expand();

if(this.Nodes==null&

&

this.Nodes.Length==0)

if(ToTreeNode!

=null&

this.Nodes.Length==0)

returnToTreeNode;

ToTreeNode.Nodes.Add(this.Nodes.ToTreeNode());

///加载TreeView

publicstaticvoidLoadTreeViewData(TreeViewtreeView,stringpath)

BinaryFormatterser=newBinaryFormatter();

Streamfile=newFileStream(path,FileMode.Open,FileAccess.Read,FileShare.Read);

TreeViewDatatreeData=((TreeViewData)(ser.Deserialize(file)));

treeData.PopulateTree(treeView);

file.Close();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1