当前位置:网站首页>Use treeview tree menu bar (recursively call database to create menu automatically)
Use treeview tree menu bar (recursively call database to create menu automatically)
2020-11-09 12:12:00 【Irving the procedural ape】
When doing industrial control PC project , When the project is too big , There are a lot of subdivision processes , The number of pages that need to be managed will also increase a lot , You can use .NET Control TreeView Page switch management , And realize TreeView Between the mutual switch .Intouch and Wonderware You can import and use TreeView Control .
One 、 Use VS Development TreeView Control
Create a control project solution
Drag one TreeView Control , You can simply edit nodes

Tag It's data that needs to be passed out

Two 、 What happened
At the end of the project , The other party will put forward a lot of improvement needs , At this point, if there are too many TreeView Control , Every time we improve , For the upper computer system, it needs to import again , There's too much repetition , Too complicated .
Solution : Create menu table in database , The menu bar is automatically generated when the project is running
3、 ... and 、 Create database
Create database tables ,MenuId It's the menu number ,MenuName by TreeView The name of the page displayed ,MenuCode by Tag,ParentId This node is the root of the node

Four 、 Write code and generate it automatically
According to the two-tier architecture

Entity class TreeViewNode
1 public class TreeViewNode 2 { 3 public int MenuId { get; set; } 4 5 public string MenuName { get; set; } 6 7 public string MenuCode { get; set; } 8 9 public string ParentId { get; set; }10 }
Service layer :MenuService
1 /// <summary> 2 /// Get all the menu items 3 /// </summary> 4 /// <returns></returns> 5 public List<TreeViewNode> GetAllMenu() 6 { 7 string sql = "select MenuId,MenuName,MenuCode,ParentId from MenuList"; 8 List<TreeViewNode> nodeList = new List<TreeViewNode>(); 9 SqlDataReader objRead = SQLHelper.GetReader(sql);10 while (objRead.Read())11 {12 nodeList.Add(new TreeViewNode()13 {14 MenuId = Convert.ToInt32(objRead["MenuId"]),15 MenuName = objRead["MenuName"].ToString(),16 MenuCode = objRead["MenuCode"].ToString(),17 ParentId = objRead["ParentId"].ToString()18 });19 }20 objRead.Close();21 return nodeList;22 }
TreeViewMenu Control :
1 public partial class TreeViewMenu: UserControl 2 { 3 public TreeViewMenu() 4 { 5 InitializeComponent(); 6 Lo.........
版权声明
本文为[Irving the procedural ape]所创,转载请带上原文链接,感谢
边栏推荐
- After SQL group query, get the first n records of each group
- Stack & queue (go) of data structure and algorithm series
- jsliang 求职系列 - 08 - 手写 Promise
- Visit Jingdong | members of Youth Innovation Alliance of China Academy of space technology visit Jingdong headquarters
- For and for... In, for each and map and for of
- Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
- Show profile analysis of SQL statement performance overhead
- 嗯,查询滑动窗口最大值的这4种方法不错...
- As a user, you can't get rid of the portrait!
- TiDB x 微众银行 | 耗时降低 58%,分布式架构助力实现普惠金融
猜你喜欢

Android架构之Navigation组件(二)

分库分表的 9种分布式主键ID 生成方案,挺全乎的

Shoes? Forecasting stock market trends? Taobao second kill? Python means what you want

JVM学习(五) -执行子系统

关于无相互作用极化率的计算

In the future, China Telecom will make cloud computing service the main business of China Telecom

Reading design patterns adapter patterns

配置交换机Trunk接口流量本地优先转发(集群/堆叠)

使用TreeView树型菜单栏(递归调用数据库自动创建菜单)

【golang】GC详解
随机推荐
Review of hot spots of last week (11.2-11.8)
Introduction to zero based im development (4): what is message timing consistency in IM systems?
安卓开发——服务应用,计时器的实现(线程+服务)
接口测试如何在post请求中传递文件
为wget命令设置代理
Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way
在嵌入式设备中实现webrtc的第三种方式③
On the calculation of non interaction polarizability
Understanding task and async await
如何用函数框架快速开发大型 Web 应用 | 实战
Analysis of the source code of ThinkPHP facade
Using stream to read and write files to process large files
理解 OC 中 RunLoop
android studio AIDL的使用
Oh, my God! Printing log only knows log4j?
Handwriting Koa.js Source code
10款必装软件,让Windows使用效率飞起!
Recommended tools for Mac
真正拖垮你的,是沉没成本
通配符SSL证书应该去哪里注册申请