当前位置:网站首页>C#(二十九)之C#listBox checkedlistbox imagelist
C#(二十九)之C#listBox checkedlistbox imagelist
2022-07-06 03:39:00 【camellias_】
listBox属性:
Items:所有选项
SelectionMode:是否支持多选
(1):one 只能选择一个
(2):Multisimple 可选择多个
(3):MultExtended 按组合键可多选
(4):none 不可选择
Multicolnum:
true:支持水平排列
false:不支持水平排列
SelectedIndex
listbox选项的索引是从0开始排列的。
Checklistbox
Items:所有选项
CheckOnClick
False:需要双击才能选中选项
True:单击便可选中选项
Imagelist 组件
Images:
组件中图片集合 使用数组表示
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CBeNjYHK-1655864764074)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/d545a3c973ff45d0b1eb310cb4b34549~tplv-k3u1fbpfcp-zoom-1.image "1555393498465220.png")]](/img/b2/8186cea1d3c554a9ef649ef0df147c.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 putButton_Click(object sender, EventArgs e)
{
int index = listBox1.SelectedIndex;
if(index == 0)
{
result.Text = listBox1.SelectedItem.ToString();
}
else if(index == 1)
{
result.Text = listBox1.SelectedItem.ToString();
}
else if (index == 2)
{
result.Text = listBox1.SelectedItem.ToString();
}
else
{
MessageBox.Show("请选择选项");
}
}
/**
* 添加按钮
*/
private void Add_Click(object sender, EventArgs e)
{
listBox1.Items.Add(Input.Text);
Input.Clear();
}
/**
* 移除按钮
*/
private void Remove_Click(object sender, EventArgs e)
{
int sel = listBox1.SelectedIndex;
if (sel != -1)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
else
{
MessageBox.Show("请选择需要移除的选项");
}
}
/**
* 清空按钮
*/
private void Clear_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
/**
* 复选框默认事件
* 选中文字打勾才会执行(在不修改CheckOnClick属性时需要双击才会打勾)
*/
private void fubox_SelectedIndexChanged(object sender, EventArgs e)
{
}
/**
* 复选框默认事件
* 选中文字(不打勾)就会执行
*/
private void fubox_ItemCheck(object sender, ItemCheckEventArgs e)
{
// e是参数对象,等于被选中的那个值
if (e.NewValue == CheckState.Checked)
{
// 选中的主键(选中之后显示图片)
switch (e.Index)
{
case 0: pictureBox1.Image = imageList1.Images[0]; break;
case 1: pictureBox2.Image = imageList1.Images[1]; break;
case 2: pictureBox3.Image = imageList1.Images[2]; break;
case 3: pictureBox4.Image = imageList1.Images[3]; break;
}
}
else
{
// 未选中的主键(去掉选中之后图片消失)
switch (e.Index)
{
case 0: pictureBox1.Image = null; break;
case 1: pictureBox2.Image = null; break;
case 2: pictureBox3.Image = null; break;
case 3: pictureBox4.Image = null; break;
}
}
}
}
}
有好的建议,请在下方输入你的评论。
欢迎访问个人博客
https://guanchao.site
欢迎访问小程序:

边栏推荐
- [prediction model] difference method model
- Brush questions in summer -day3
- ESBuild & SWC浅谈: 新一代构建工具
- Suggestions for new engineer team members
- Schnuka: what is visual positioning system and how to position it
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
- 简述C语言中的符号和链接库
- 【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
- C language judgment, ternary operation and switch statement usage
- How to write compile scripts compatible with arm and x86 (Makefile, cmakelists.txt, shell script)
猜你喜欢

Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
![[optimization model] Monte Carlo method of optimization calculation](/img/e6/2865806ffbbfaa8cc07ebf625fcde6.jpg)
[optimization model] Monte Carlo method of optimization calculation

BUAA calculator (expression calculation - expression tree implementation)

2.2 STM32 GPIO operation

Blue style mall website footer code

EDCircles: A real-time circle detector with a false detection control 翻译

Python implementation of maddpg - (1) openai maddpg environment configuration
![[analysis of variance] single factor analysis and multi factor analysis](/img/92/5337d0ef6e487d1af2f56cb3a3268a.jpg)
[analysis of variance] single factor analysis and multi factor analysis

Pytorch基础——(1)张量(tensor)的初始化

Edcircles: a real time circle detector with a false detection control translation
随机推荐
遥感图像超分辨率论文推荐
[slam] orb-slam3 parsing - track () (3)
数据分析——seaborn可视化(笔记自用)
SWC介绍
StrError & PERROR use yyds dry inventory
Cubemx 移植正点原子LCD显示例程
Explore pointers and pointer types in depth
【Qt5】Qt QWidget立刻出现并消失
Crawler of explanation and application of agency theory
Differential GPS RTK thousand search
Redo file corruption repair
[Massey] Massey font format and typesetting requirements
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
[padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
Basic concepts of LTE user experience
pytorch加载数据
ASU & OSU | model based regularized off-line meta reinforcement learning
Multi project programming minimalist use case
[matlab] - draw a five-star red flag