当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- JVM learning (4) - garbage collector and memory allocation
- From coding, network transmission, architecture design, Tencent cloud high quality, high availability real-time audio and video technology practice
- 线上服务的FGC问题排查,看这篇就够了!
- Show profile analysis of SQL statement performance overhead
- 手写Koa.js源码
- “开源软件供应链点亮计划 - 暑期 2020”公布结果 基于 ChubaoFS 开发的项目获得最佳质量奖
- nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)
- Handwritten digital image recognition convolution neural network
- Three practical skills of Medical Project Management
- How to query by page after 10 billion level data is divided into tables?
猜你喜欢
一个简单的能力,决定你是否会学习!
接口测试如何在post请求中传递文件
Setting up a proxy for the WGet command
分库分表的 9种分布式主键ID 生成方案,挺全乎的
Visit Jingdong | members of Youth Innovation Alliance of China Academy of space technology visit Jingdong headquarters
在企业的降本增效诉求下,Cube如何助力科盾业务容器化“一步到位”?
天啦撸!打印日志竟然只晓得 Log4j?
android studio AIDL的使用
Oh, my God! Printing log only knows log4j?
开源ERP招聘了
随机推荐
Android权限大全
How to query by page after 10 billion level data is divided into tables?
Download Netease cloud music 10W + music library with Python
Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way
嗯,查询滑动窗口最大值的这4种方法不错....
nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)
“开源软件供应链点亮计划 - 暑期 2020”公布结果 基于 ChubaoFS 开发的项目获得最佳质量奖
Suning's practice of large scale alarm convergence and root cause location based on Knowledge Map
An attempt to read or write to protected memory occurred using the CopyMemory API. This usually indicates that other memory is corrupted.
配置交换机Trunk接口流量本地优先转发(集群/堆叠)
In the future, China Telecom will make cloud computing service the main business of China Telecom
After SQL group query, get the first n records of each group
Safety (miscellany)
inet_pton()和inet_ntop()函数详解
SHOW PROFILE分析SQL语句性能开销
Android Studio Avd「真·小白食用方法」
Jsliang job series - 08 - handwritten promise
The third way to realize webrtc in embedded devices
Android rights
【golang】GC详解