当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 服务应用 ClockService安卓实现闹钟
- jsliang 求职系列 - 08 - 手写 Promise
- 共创爆款休闲游戏 “2020 Ohayoo游戏开发者沙龙”北京站报名开启
- 大型项目Objective-C - NSURLSession接入短信验证码应用实例分享
- 注意.NET Core进行请求转发问题
- Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
- Adobe Experience Design /Xd 2020软件安装包(附安装教程)
- Wechat circle
- 微信圈子
- libssl对CentOS登录的影响
猜你喜欢

How to ensure that messages are not consumed repeatedly? (how to ensure the idempotent of message consumption)

Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive

Where should wild card SSL certificate register and apply

Show profile analysis of SQL statement performance overhead

Introduction to zero based im development (4): what is message timing consistency in IM systems?

《内网安全攻防》配套视频 之 利用PS查询域内信息

理解 OC 中 RunLoop

Understanding data structures starts with this article~

Analysis of the source code of ThinkPHP facade

Jsliang job series - 08 - handwritten promise
随机推荐
Solve the problem of idea shortcut key Alt + insert invalid
医疗项目管理的三种实用技巧
Using stream to read and write files to process large files
jsliang 求职系列 - 08 - 手写 Promise
Safety (miscellany)
【golang】GC详解
零基础IM开发入门(四):什么是IM系统的消息时序一致性?
The middle stage of vivo Monkey King activity
《内网安全攻防》配套视频 之 利用PS查询域内信息
Understanding data structures starts with this article~
Large scale project Objective-C - nsurlsession access SMS verification code application example sharing
Jsliang job series - 08 - handwritten promise
How to use function framework to develop large web application
JVM learning (5) - execution subsystem
Chrome browser engine blink & V8
A simple ability determines whether you will learn!
Interface tests how to pass files in post requests
Android权限大全
Adobe Experience Design /Xd 2020软件安装包(附安装教程)
[design pattern] Chapter 4: Builder mode is not so difficult