当前位置:网站首页>C (XXIX) C listbox CheckedListBox Imagelist
C (XXIX) C listbox CheckedListBox Imagelist
2022-07-06 03:47:00 【camellias_】
listBox attribute :
Items: All options
SelectionMode: Whether to support multiple selection
(1):one You can only choose one
(2):Multisimple Multiple choices available
(3):MultExtended Press the key combination to select more
(4):none There is no choice
Multicolnum:
true: Support horizontal arrangement
false: Horizontal arrangement is not supported
SelectedIndex
listbox The index of the option is from 0 At the beginning of the alignment .
Checklistbox
Items: All options
CheckOnClick
False: You need to double-click to select the option
True: Click to select the option
Imagelist Components
Images:
Set of pictures in the component Use an array to represent
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 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(" Please choose the option ");
}
}
/**
* Add a button
*/
private void Add_Click(object sender, EventArgs e)
{
listBox1.Items.Add(Input.Text);
Input.Clear();
}
/**
* Remove button
*/
private void Remove_Click(object sender, EventArgs e)
{
int sel = listBox1.SelectedIndex;
if (sel != -1)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
else
{
MessageBox.Show(" Please select the option you want to remove ");
}
}
/**
* Clear button
*/
private void Clear_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
/**
* Check box default event
* Check the text to execute ( Don't modify CheckOnClick You need to double-click to check the attribute )
*/
private void fubox_SelectedIndexChanged(object sender, EventArgs e)
{
}
/**
* Check box default event
* Select the text ( Don't tick ) Will execute
*/
private void fubox_ItemCheck(object sender, ItemCheckEventArgs e)
{
// e It's a parameter object , Equal to the selected value
if (e.NewValue == CheckState.Checked)
{
// Selected primary key ( Select to display the picture )
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
{
// Unselected primary key ( After removing the selection, the picture disappears )
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;
}
}
}
}
}
There are good suggestions , Please enter your comments below .
Welcome to personal blog
https://guanchao.site
Welcome to the applet :
边栏推荐
- RT thread -- FTP of LwIP (2)
- 施努卡:什么是视觉定位系统 视觉系统如何定位
- [practical exercise] face location model based on skin color
- [001] [stm32] how to download STM32 original factory data
- A brief introduction to symbols and link libraries in C language
- How to standardize the deployment of automated testing?
- 登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
- Pytoch foundation - (1) initialization of tensors
- 简述C语言中的符号和链接库
- P7735-[noi2021] heavy and heavy edges [tree chain dissection, line segment tree]
猜你喜欢
【按键消抖】基于FPGA的按键消抖模块开发
Mysqldump data backup
SWC介绍
Map sorts according to the key value (ascending plus descending)
mysql关于自增长增长问题
[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
SWC introduction
BUAA计算器(表达式计算-表达式树实现)
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
Blue Bridge Cup - day of week
随机推荐
Deno介绍
简易博客系统
[001] [stm32] how to download STM32 original factory data
Factors affecting user perception
No qualifying bean of type ‘......‘ available
Blue Bridge Cup - Castle formula
遥感图像超分辨率论文推荐
【FPGA教程案例12】基于vivado核的复数乘法器设计与实现
Yyds dry inventory what is test driven development
JS Vanke banner rotation chart JS special effect
如何修改表中的字段约束条件(类型,default, null等)
Restful style
BUAA magpie nesting
[practice] mathematics in lottery
[slam] orb-slam3 parsing - track () (3)
Pelosi: Congress will soon have legislation against members' stock speculation
【SLAM】ORB-SLAM3解析——跟踪Track()(3)
User experience index system
【Qt5】Qt QWidget立刻出现并消失
Multi project programming minimalist use case