当前位置:网站首页>C form application treeview control use
C form application treeview control use
2022-07-24 20:05:00 【InfoQ】
Preface :
Once a day , Prevent puppy love

1.TreeView Control use
1.1 TreeView Control common properties
Index Get the position of the tree node in the tree node collection
Nodes Gets the collection of tree nodes assigned to the tree view control
Parent Gets or sets the parent container of the control
SelectedNode Gets or sets the tree node currently selected in the tree view control
ExpandAll Expand all tree nodes
Checked Gets or sets a value , Used to indicate whether the tree node is selected
Text Gets or sets the text displayed in the tree node label
Expand Expand tree node
Clear Empty the tree
Remove Removes the current tree node from the tree view control .
1.2 Create a form file and change the name

2. Design interface

3. Add and delete data
3.1 Click on treeView Edit node

3.2 stay TreeView Add data to the editor


3.3 TreeView Control to add root node operation

3.4 TreeView Control to add child nodes

3.5 TreeView Control deletion

3.6 TreeView Control to clear the tree

4. Overall effect display

4.1 Code demonstration
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TreeTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TreeNode treeNode = new TreeNode(textBox1.Text, 2, 2);
treeView1.Nodes.Add(treeNode);
treeView1.Select();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
TreeNode selectdnode = treeView1.SelectedNode;
if(selectdnode!=null)
{
TreeNode chnode = new TreeNode(textBox2.Text, 2, 2);
selectdnode.Nodes.Add(chnode);
selectdnode.Expand();
treeView1.Select();
}
else
{
MessageBox.Show(" Please select the child node you want to add ");
}
}
private void button3_Click(object sender, EventArgs e)
{
TreeNode selectnode = treeView1.SelectedNode;
TreeNode parentnode = selectnode.Parent;
if(parentnode == null)
{
treeView1.Nodes.Remove(selectnode);
}
else
{
parentnode.Nodes.Remove(selectnode);
}
treeView1.Select();
}
private void button4_Click(object sender, EventArgs e)
{
treeView1.Nodes.Clear();
}
private void button5_Click(object sender, EventArgs e)
{
this.textBox1.Clear();
this.textBox2.Clear();
}
}
}
summary :

边栏推荐
- Modbus communication protocol specification (Chinese) sharing
- [trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
- Anaconda installs labelimg (super simple and available)
- Getting started with COM programming 1- creating projects and writing interfaces
- Thymeleaf application notes
- 存储类别
- Istio II traffic hijacking process
- Work notes - some problems encountered when using jest
- Pure C implementation -------- Nicolas theorem
- Batch download files from the server to the local
猜你喜欢

Substr and substring function usage in SQL

How to export map files tutorial

聊下自己转型测试开发的历程

Common methods of string class
![Leetcode 300 longest increasing subsequence (greedy + binary search for the first element subscript smaller than nums[i]), leetcode 200 island number (deep search), leetcode 494 target sum (DFS backtr](/img/60/6b75484a65a49c6e20c2b79c062310.png)
Leetcode 300 longest increasing subsequence (greedy + binary search for the first element subscript smaller than nums[i]), leetcode 200 island number (deep search), leetcode 494 target sum (DFS backtr

Introduction to WDK development 1- basic environment construction and the first driver (VS2010)

Day 9 (this keyword and experiment)

Description of large and small end mode

Batch download files from the server to the local

Virtual machine win7 system installation vmtool
随机推荐
2019 Hangzhou Electric Multi School Game 7 6651 final exam [Law + thinking]
Day 5 (array)
Common methods of string class
01 | opening words: teach you to build a blog website hand in hand
Sword finger offer 53 - I. find the number I in the sorted array
Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
01 | 开篇词:手把手教你搭建一个博客网站
Look at the interface control devaxpress WinForms - how to customize auxiliary function properties (Part 2)
Getting started with COM programming 1- creating projects and writing interfaces
Bypass using the upper limit of the maximum number of regular backtracking
Siyuan notes V2.1.2 synchronization problem
Redis basic knowledge, application scenarios, cluster installation
Istio二之流量劫持过程
Data transmission of different fragments in the same activity
Analysis and Simulation of strlen function
872. Maximum common divisor
Solutions to oom caused by pictures in res directory
Day 10 (inheritance, rewriting and use of super)
Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
02 | environment preparation: how to install and configure a basic PHP development environment under windows?