当前位置:网站首页>C (thirty) C combobox listview TreeView
C (thirty) C combobox listview TreeView
2022-07-06 03:47:00 【camellias_】
comboBox Drop down list box properties
Items: Drop down list box options
DropDownStyle: Control the appearance and function of the combo box
Simple: Single style
DropDown: Default style ( You can enter )
DropDownList: It looks the same as the default style , But it is not allowed to enter .
ListView List view properties
Activeation:
Standard: Standard events that occur when icons are double clicked consecutively
Oneclick: Events that occur on a single machine
Twoclick: There is no need to double-click continuously , Two single machines
Largeimagelist: Store large icon collections
Smallimagelist: Store a collection of small icons
View: Display style
Tile: tile
List: list
LargeIcon: Large icon
SmallIcon: Small icons
Details: detailed
Columns: Columns displayed in the details view
ListView List view events
ItemActive: Occurs when an item is activated .
columnClick: Occurs when a column header is clicked .
treeView Tree view properties :
nodes: Control
imageindex: Selected image
selectimageindex: The selected picture
SelectNode: Selected node
As shown in the figure below :
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-nORX28aQ-1656122785106)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/dadc087da6d34099ad4c4bc62d92406e~tplv-k3u1fbpfcp-zoom-1.image “1555492312851584.png”)]
The test uses all the code
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 _0416Day
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int num = comboBox1.SelectedIndex;
if( num == 0)
{
label1.ForeColor = Color.LightPink;
}
else if(num == 1)
{
label1.ForeColor = Color.BlueViolet;
}
else if(num == 2)
{
label1.ForeColor = Color.Blue;
}
else if (num == 3)
{
label1.ForeColor = Color.Coral;
}
}
/**
* Tile button
*/
private void button1_Click(object sender, EventArgs e)
{
listView.View = View.Tile;
}
/**
* List button
*/
private void button2_Click(object sender, EventArgs e)
{
listView.View = View.List;
}
/**
* Large icon button
*/
private void button3_Click(object sender, EventArgs e)
{
listView.View = View.LargeIcon;
}
/**
* Small icon button
*/
private void button4_Click(object sender, EventArgs e)
{
listView.View = View.SmallIcon;
}
/**
* Detailed button
*/
private void button5_Click(object sender, EventArgs e)
{
listView.View = View.Details;
}
private void listView_ItemActivate(object sender, EventArgs e)
{
// Get the corresponding document path
string mydoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string mymusic = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
switch(listView.SelectedIndices[0])
{
case 0:System.Diagnostics.Process.Start("calc");break;
case 1: System.Diagnostics.Process.Start(mydoc); break;
case 2: System.Diagnostics.Process.Start("IExplore"); break;
case 3: System.Diagnostics.Process.Start(mymusic); break;
case 4: System.Diagnostics.Process.Start("notepad"); break;
}
}
private void listView_ColumnClick(object sender, ColumnClickEventArgs e)
{
if (listView.Sorting == SortOrder.None)
{
listView.Sorting = SortOrder.Ascending;
}
else if (listView.Sorting == SortOrder.Ascending)
{
listView.Sorting = SortOrder.Descending;
}
else
{
listView.Sorting = SortOrder.Ascending;
}
}
private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
{
// Get the corresponding document path
string mydoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string mymusic = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
switch (e.Node.Text)
{
case " Calculator ": System.Diagnostics.Process.Start("calc"); break;
case " My computer ": System.Diagnostics.Process.Start(mydoc); break;
case " my IE": System.Diagnostics.Process.Start("IExplore"); break;
case " My music ": System.Diagnostics.Process.Start(mymusic); break;
case " My notebook ": System.Diagnostics.Process.Start("notepad"); break;
}
}
/**
* Select Add node in the project
*/
private void button7_Click(object sender, EventArgs e)
{
TreeNode cyaa = new TreeNode("cyaa");
cyaa.ImageIndex = 0;
cyaa.SelectedImageIndex = 0;
treeView.SelectedNode.Nodes.Add(cyaa);
}
/**
* Add root and child nodes
*/
private void button6_Click(object sender, EventArgs e)
{
TreeNode cy1 = new TreeNode("cy1");
cy1.ImageIndex = 0;
cy1.SelectedImageIndex = 0;
treeView.Nodes.Add(cy1);
TreeNode cy1a = new TreeNode("cy1a");
cy1a.ImageIndex = 1;
cy1a.SelectedImageIndex = 1;
cy1.Nodes.Add(cy1a);
}
}
}
There are good suggestions , Please enter your comments below .
Welcome to personal blog
https://guanchao.site
Welcome to the applet :
边栏推荐
- Basic concepts of LTE user experience
- 3.2 rtthread 串口设备(V2)详解
- Ethernet port &arm & MOS &push-pull open drain &up and down &high and low sides &time domain and frequency domain Fourier
- 施努卡:什么是视觉定位系统 视觉系统如何定位
- cookie,session,Token 这些你都知道吗?
- Flask learning and project practice 9: WTF form verification
- Codeforces Global Round 19
- [rust notes] 18 macro
- Python implementation of maddpg - (1) openai maddpg environment configuration
- 阿里测试师用UI自动化测试实现元素定位
猜你喜欢
ESBuild & SWC浅谈: 新一代构建工具
Do you know cookies, sessions, tokens?
Mysqldump data backup
BUAA magpie nesting
给新人工程师组员的建议
P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]
Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
How to modify field constraints (type, default, null, etc.) in a table
[001] [stm32] how to download STM32 original factory data
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
随机推荐
Schnuka: 3D vision detection application industry machine vision 3D detection
Pytorch基础——(1)张量(tensor)的初始化
Pelosi: Congress will soon have legislation against members' stock speculation
Why do you want to start pointer compression?
MySQL reads missing data from a table in a continuous period of time
暑期刷题-Day3
Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
如何修改表中的字段约束条件(类型,default, null等)
Shell pass parameters
[optimization model] Monte Carlo method of optimization calculation
cookie,session,Token 这些你都知道吗?
RT thread -- FTP of LwIP (2)
How do we make money in agriculture, rural areas and farmers? 100% for reference
BUAA calculator (expression calculation - expression tree implementation)
RT-Thread--Lwip之FTP(2)
Recommended papers on remote sensing image super-resolution
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
简易博客系统
Crawler of explanation and application of agency theory
[001] [stm32] how to download STM32 original factory data