当前位置:网站首页>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 :

边栏推荐
- 从服务器批量下载文件到本地
- Xiaomi 12s ultra products are so powerful, but foreigners can't buy Lei Jun: first concentrate on the Chinese market
- Analysis and Simulation of strlen function
- SSL Error: Unable to verify the first certificate
- Introduction and advanced tutorial of Albert duilib
- "Hualiu is the top stream"? Share your idea of yyds
- 872. Maximum common divisor
- 2019 Hangzhou Electric Multi School Game 7 6651 final exam [Law + thinking]
- Using videoview to realize video playback in turns
- Day 5 (array)
猜你喜欢

从码农转型大音乐家,你只差这些音乐处理工具

Analysis and Simulation of strlen function

Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack

Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second

Redis basic knowledge, application scenarios, cluster installation

How to encrypt your own program with dongle

Risk control system, implemented by flink+clickhouse!

01 | opening words: teach you to build a blog website hand in hand

Todolist case

Basic idea of regularization
随机推荐
Safe way -- Analysis of single pipe reverse connection back door
Monotone stack and monotone queue (linear complexity optimization)
纯C实现----------尼科彻斯定理
Description of large and small end mode
Flink window & time principle
Getting started with COM programming 1- creating projects and writing interfaces
The difference between delete, truncate and drop in MySQL
How to encrypt your own program with dongle
Is the incremental update of SQL Server database identified according to the where clause? Can't do stream update? Each table should
拿捏C指针
Day 9 (this keyword and experiment)
What is IDE (integrated development environment)
Hold the C pointer
Data transmission of different fragments in the same activity
Batch download files from the server to the local
Recursion of function [easy to understand]
2019 Hangzhou Electric Multi School Game 7 6651 final exam [Law + thinking]
[trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
Unity2d~ game practice of decrypting Zhou mu (completed in three days)
01 | opening words: teach you to build a blog website hand in hand