treeview问题 ~!!!!大家来HELP ME 谢谢

qqws 2003-07-26 09:44:45
看了很多TREEVIEW的帖子跟资料,还是没弄明白怎么动态加载数据,请高手指教下,请把过程给详细点,我刚开始学的,谢谢大家了,请关照小弟 分不够可以加

结构:
人力资源部
人员名字
财务部
人员名字
后勤部
人员名字
大楷就这样的个模式,数据试在数据库里面的,麻烦把数据库结构也告诉我,再次感谢了,急,
...全文
132 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jpusaddam 2004-01-08
  • 打赏
  • 举报
回复
http://search.csdn.net/expert/topic/52/5202/2003/3/13/1525202.htm
jeall 2004-01-07
  • 打赏
  • 举报
回复
Thanks! jeall@163.com
qqws 2003-07-27
  • 打赏
  • 举报
回复
?///???
qqws 2003-07-27
  • 打赏
  • 举报
回复
还是有问题啊,对了,还有个问题,我用DATAVIEW筛选了记录后,我怎么把筛选的记录副到一个字符串上去啊,
dahuzizyd 2003-07-27
  • 打赏
  • 举报
回复
你直接拷贝就可以用了啊
qqws 2003-07-27
  • 打赏
  • 举报
回复
大家再给点详细的例子把,还是不太明白
qqws 2003-07-27
  • 打赏
  • 举报
回复
sheng.wan@tom.com
雪狼1234567 2003-07-26
  • 打赏
  • 举报
回复
给我mail发一个给你
dahuzizyd 2003-07-26
  • 打赏
  • 举报
回复
在web下,我是使用一个全局静态变量来保存selectedIndex
string static CurrentNodeIndex ;
CurrentNodeIndex = TreeView1.SelectedNodeIndex;
另:上面的根据selectedIndex来遍历树查找节点,错了,应该是SelectNodeIndex
dahuzizyd 2003-07-26
  • 打赏
  • 举报
回复
我的这个和你的不太一样,人员是在另一个表里的,向你的直接象下面的结构,把人员的ParentID设为他的父节点的ID就可以了:
部门信息表:
DepID ParentID Name
100001 0 技术部
100002 0 财务部
100003 100001 编码组
100004 100001 测试组

建表的过程:需要先声明一个 DataView dv
public void InitTree(TreeNodeCollection Nds,string parentId,DataSet ds,string TableName)
{ //从根节点开始递归调用显示子树
dv=new DataView();
TreeNode tmpNd;
string intId;
dv.Table=ds.Tables[TableName];
dv.RowFilter="ParentId=" + parentId ;
foreach(DataRowView drv in dv)
{ //递归算法从这里开始。
tmpNd=new TreeNode();
tmpNd.Tag =drv[0].ToString(); //节点ID
tmpNd.Text=drv[2].ToString(); //节点名称
Nds.Add(tmpNd);
intId=drv[1].ToString(); //节点的父节点
InitTree(tmpNd.Nodes,tmpNd.Tag.ToString(),ds,TableName);
}
}
四个参数:TreeNodeCollection Nds就是你要生成的树,例如:treeView1
ParentID 父节点名称,初始时为0 后面两个我就不说了。
另外,在添加节点时判断是否已有相同名称的节点存在可以用递归:
public void GetAllNodeText(TreeNodeCollection tnc,string txt)
{
foreach (TreeNode node in tnc)
{
if( node.Nodes.Count != 0 )
GetAllNodeText(node.Nodes,txt);
}
}
我的添加节点时只判断同级节点是否有重名的:
public bool AddNode(TreeNode SelNode,string ID,string txt)
{
int exist = 0;
TreeNode NewNode = new TreeNode();
NewNode.Text = txt;
NewNode.Tag = ID;
foreach (TreeNode tnc in SelNode.Nodes )
{
if (tnc.Text == txt)
{
exist = 1;
return false;
}

}
if (exist != 1)
{
SelNode.Nodes.Add(NewNode);
return true;
}
else
{
return false;
}
}
删除就很简单了
public bool DeleteNode(TreeNode DelNode)
{
if ( DelNode.Nodes.Count == 0)
{
DelNode.Remove();
return true;
}
else
{
return true;
}
}

以上是winform下的,web应用下的你要先装上web下的treeView控件,实现方法查不多,主要是类型不一样,而且webTreeView1在添加和删除节点时,由于没有selectedNode的概念,所以要根据selectedIndex来遍历树查找节点,然后添加或删除,代码太多,就不贴上来了。
这些你可以作在一个类下,在前台界面引用,然后使用里面的方法。
qqws 2003-07-26
  • 打赏
  • 举报
回复
怎么没人回贴啊
1 , vb5dialog.zipThis demonstrates how to subclass the Common Dialog Dialogs and manipulate a specific Dialog.2 , cpnl.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).3 , vbo_progbar.zipImplement a common control progress bar with added features that are not accessable using COMCTL32.OCX! 4 , vbo_infolabel.zipThis control adds a great user-friendly interface with and icon and "Hover" ability. Based on a control seen in ICQ. 5 , vbo_checkcombo.zipAdd a checkbox to a combo box and use it to enabled/disable the combo! or whatever you would like to do with it! 6 , vbo_controlframe.zipCreate your own system button such as a Maximize, Minimize, Close, and many others with ease! 7 , vbo_ctextbox.zipThis class makes using the Textbox or Edit class API simple. Easily set properties and access many features not available directly from VB. 8 , taskbar.zipForm_Taskbar is a control for Visual Basic which, once placed onto a form, makes the form act like the Taskbar (minus the Start Menu).9 , NT_Service.zipThis is an OCX that allows you to create an NT service application...add the control to your project and register it as a service!!10 , Scroller.zipThis is a Control Container, it's like a frame control but it lets you scroll the content up and down...11 , TrayArea.zipThis control lets you add your icon to the System Tray Area and handle some events such as MouseMove, MouseDown, MouseUp and DblClick.12 , Resizer.zipThis is a very useful control: It's a container control, you can insert two controls inside and then you'll have a vertical (or horizontal) resizer bar (like the Windows File Explorer). A resizer can contain another resizer... an so on. (you can divide you form in as many sizable sections as you want...).13 , Label3D.zipTh
Note that Delphi IDE does not move components to the new default place on components palette when you install new version of same component(s). So if you already has EhLib installed, then installation new (3.0) version does not move EhLib components to the 'EhLib' page. To force Delphi IDE to move compontes to the default place on components palette do next: Open menu: Component->Configure Palette. Select '[All]' line in Pages listbox. Click 'Default Pages' button. 4. Installation Help ----------------- 1. This version of library doesn't have help files for Delphi8 and Delphi2005. 2. Delphi 4.x - 7.x: Copy the EhLib.hlp and EhLib.cnt files to the Delphi HELP subdirectory. Select Help|Customize to start the OpenHelp application. Add the EhLib.cnt file to the Contents page, add the EhLib.hlp file to the Index and Link pages. 3. C++Builder 4.x - 6.x: Copy the EhLib.hlp and EhLib.cnt files to the C++Builder HELP subdirectory. Select Help|Customize to start the OpenHelp application. Add the EhLib.cnt file to the Contents page, add the EhLib.hlp file to the Index and Link pages. 5. Demonstration Programs ---------------------- Demonstration programs use tables from the DEMOS directory and BDE alias "DBDEMOS". DEMOS/DEMO1 - Demonstration of use TDBGridEh, TPrintDBGridEh, TDBLookupComboboxEh and TPreviewBox. Requare EhLibBDE.Pas file from DataService directory DEMOS/DirTree - Demonstration of use TDBGridEh and TMemTableEh in tree-view mode. DEMOS/IbDemo - Demonstration of use TMemTableEh, TBDEDataDriverEh. DEMOS/MasterDetailType3 - Demonstration of master/detail relation for TMemTableEh component. DEMOS/SQLDataDriver - Demonstration of use TSQLDataDriver. DEMOS/TreeView - Demonstration of use TDBGridEh and TMemTableEh in tree-view mode
SkinEngine3.4.7 SkinEngine is an VCL library that allows you to dynamically change almost any aspect of the visual appearance your project's forms or controls. SkinEngine provides you with full support for application skins. Skins support for forms, menus and controls. SkinEngine using the internal skin files for provide new visual appearance for your project's. Also SkinEngine include powerful tools for create your own skins - SkinBuilder. # What's New in SkinEngine 3.4.7 # + Fixed: GDI resource leaks on TSeCustomForm + Fixed: SeBitmapLink memory leaks + Fixed: Scrollbars not hide in Memo, ListView, TreeView, ScrollBox # Technical Support # Technical support for KSDev software is provided through email and newsgroups on our news server. For latest news and support visit KSDev's newsgroups. Please, address general questions to the newsgroup. To obtain technical support for any of the KSDev's products, please send an electronic mail message to support@ksdev.com. Be sure to include a detailed description of the problem you are having in addition to the following information: * Version number of KSDev software * Name and version number of development tool (i.e. Delphi 4.01) * Windows 95/98/Me/NT/2000/XP version (including service packs and other fixes installed), US or international, OEM or not computer information: CPU type and speed, amount of memory installed description of your problem (as much information as possible to retrieve the problem) We'll try to help you as fast as possible, usually in one or two business days. # KSDev's Products # # FXLib # FXLib is an easy-to-use set of components that enables you to create amazing splash screens, form and image transition effects, using all the power of its advanced rendering engine. Over 70 families of animation and transition effects with hundreds of variations. Real-time rendering. WYSIWYG editing in both design-time and run-time, preview. # ThemeEngine # ThemeEngine is an VCL library that allows you to change almost any aspect of the visual appearance your project's forms, menus and controls. ThemeEngine provides you application full themes support. ThemeEngine support new Windows XP style and simulation for other Windows platform. # MediaPack # MediaPack allows to you create of application with cool GUI. Forms of any shape, background with bitmaps tile, gradient or plasma fill, original border with bitmaps or solid fill. Advanced multimedia controls with cool background and borders. MediaPack is a over 70 advanced multimedia components and controls. # FreeSkinEngine # SkinEngine is an VCL library that allows you to dynamically change almost any aspect of the visual appearance your project's forms or controls. In short, it provides you with full support for application skins. It's even possible to make your program look like an application from any other OS, or create your own user WindowBlinds-like or NeoPlanet-like "skinned" interface. # FreeVCL # FreeVCL is a library of almost 20 visual components mostly Office 2k simulation

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧