当前位置:网站首页>C#(三十)之C#comboBox ListView treeView
C#(三十)之C#comboBox ListView treeView
2022-07-06 03:39:00 【camellias_】
comboBox下拉列表框属性
Items:下拉列表框选项
DropDownStyle:控制组合框的外观和功能
Simple:单一的样式
DropDown:默认样式(可输入)
DropDownList:与默认样式看着一样,但不可输入。
ListView 列表视图属性
Activeation:
Standard:标准连续双击图标所发生的事件
Oneclick:单机发生的事件
Twoclick:不需要连续双击,两次单机即可
Largeimagelist:存储大图标集合
Smallimagelist:存储小图标集合
View:显示样式
Tile:平铺
List:列表
LargeIcon:大图标
SmallIcon:小图标
Details:详细
Columns:详细信息视图中显示的列
ListView 列表视图事件
ItemActive:在激活某一项时发生。
columnClick:在单击列标头时发生。
treeView树状视图属性:
nodes:控件中根节点
imageindex:选中的图片
selectimageindex:选中之后的图片
SelectNode:选中节点
如下图所示:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nORX28aQ-1656122785106)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/dadc087da6d34099ad4c4bc62d92406e~tplv-k3u1fbpfcp-zoom-1.image “1555492312851584.png”)]
测试使用全部代码
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;
}
}
/**
* 平铺按钮
*/
private void button1_Click(object sender, EventArgs e)
{
listView.View = View.Tile;
}
/**
* 列表按钮
*/
private void button2_Click(object sender, EventArgs e)
{
listView.View = View.List;
}
/**
* 大图标按钮
*/
private void button3_Click(object sender, EventArgs e)
{
listView.View = View.LargeIcon;
}
/**
* 小图标按钮
*/
private void button4_Click(object sender, EventArgs e)
{
listView.View = View.SmallIcon;
}
/**
* 详细按钮
*/
private void button5_Click(object sender, EventArgs e)
{
listView.View = View.Details;
}
private void listView_ItemActivate(object sender, EventArgs e)
{
// 获取对应文档路径
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)
{
// 获取对应文档路径
string mydoc = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string mymusic = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
switch (e.Node.Text)
{
case "计算器": System.Diagnostics.Process.Start("calc"); break;
case "我的电脑": System.Diagnostics.Process.Start(mydoc); break;
case "我的IE": System.Diagnostics.Process.Start("IExplore"); break;
case "我的音乐": System.Diagnostics.Process.Start(mymusic); break;
case "我的笔记本": System.Diagnostics.Process.Start("notepad"); break;
}
}
/**
* 选中项目中添加节点
*/
private void button7_Click(object sender, EventArgs e)
{
TreeNode cyaa = new TreeNode("cyaa");
cyaa.ImageIndex = 0;
cyaa.SelectedImageIndex = 0;
treeView.SelectedNode.Nodes.Add(cyaa);
}
/**
* 添加根节点和子节点
*/
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);
}
}
}
有好的建议,请在下方输入你的评论。
欢迎访问个人博客
https://guanchao.site
欢迎访问小程序:
边栏推荐
- 施努卡:什么是视觉定位系统 视觉系统如何定位
- Pelosi: Congress will soon have legislation against members' stock speculation
- 3分钟带你了解微信小程序开发
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
- Cubemx transplantation punctual atom LCD display routine
- 3.2 rtthread 串口设备(V2)详解
- Safety science to | travel, you must read a guide
- 【SLAM】ORB-SLAM3解析——跟踪Track()(3)
- Blue Bridge Cup - Castle formula
- mysqldump数据备份
猜你喜欢
深入刨析的指针(题解)
On Data Mining
RT thread -- FTP of LwIP (2)
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
[optimization model] Monte Carlo method of optimization calculation
Idea push rejected solution
[Li Kou] the second set of the 280 Li Kou weekly match
施努卡:3d视觉检测应用行业 机器视觉3d检测
BUAA magpie nesting
Crazy, thousands of netizens are exploding the company's salary
随机推荐
3857 Mercator coordinate system converted to 4326 (WGS84) longitude and latitude coordinates
Distributed service framework dobbo
Pytoch foundation - (2) mathematical operation of tensor
JS音乐在线播放插件vsPlayAudio.js
Factors affecting user perception
SAP ALV颜色代码对应颜色(整理)
Research on cooperative control of industrial robots
Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
指针笔试题~走近大厂
Introduction to DeNO
给新人工程师组员的建议
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
MySQL 中的数据类型介绍
How do we make money in agriculture, rural areas and farmers? 100% for reference
Explore pointers and pointer types in depth
Cross origin cross domain request
BUAA喜鹊筑巢
ASU & OSU | model based regularized off-line meta reinforcement learning
数据分析——seaborn可视化(笔记自用)
IPv6 comprehensive experiment