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

边栏推荐
- [trial experience of Yuxin micro Wiota ad hoc network protocol development kit] RT thread BSP Software package production
- How to export map files tutorial
- Lunch break train & problem thinking: thinking about the problem of converting the string formed by hour: minute: second to second
- 2019 Hangzhou Electric Multi School Game 9 6684 Rikka with game [game question]
- Safe way -- Analysis of single pipe reverse connection back door
- Lights of thousands of families in the year of xinchou
- Virtual machine win7 system installation vmtool
- Day 6 (array example)
- Description of large and small end mode
- Unity3d eventsystem (event)
猜你喜欢

Valdo2021 - vascular space segmentation in vascular disease detection challenge (2)

Usage and introduction of MySQL binlog

Original reverse compensation and size end

"Hualiu is the top stream"? Share your idea of yyds

Stop using UUID indiscriminately. Have you tested the performance gap between self incrementing ID and UUID?

day 2

Detailed explanation of ELF format (I)
![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

Student achievement management system based on PHP

Hucang integrated release of full data value, sequoiadb V5.2 online conference heavy attack
随机推荐
Mysql8.0 learning record 20 - trigger
Hook 32-bit function using the method modified to JMP instruction
871. Sum of divisors
Unity2d~ game practice of decrypting Zhou mu (completed in three days)
存储类别
clip:learning transferable visual models from natural language supervision
Introduction to fastdfs high availability
【德味】安全:如何为行人提供更多保护
[face to face experience of school recruitment] 8 real questions of pointer interview. Come and test how many you have mastered.
Detailed explanation of ELF format (I)
Excuse me: is Flink 1.14.5 compatible with MySQL CDC 2.1.0
02 | environment preparation: how to install and configure a basic PHP development environment under windows?
Wechat applet -that.setdata ({}) set complex field data
Browser local storage webstroage
What is IDE (integrated development environment)
Leetcode 560 and the subarray of K (with negative numbers, one-time traversal prefix and), leetcode 438 find all alphabetic ectopic words in the string (optimized sliding window), leetcode 141 circula
Redis common configuration description
About the largeheap attribute
Getaverse, a distant bridge to Web3
Cmake series tutorial 2 HelloWorld