当前位置:网站首页>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 :
边栏推荐
- 【FPGA教程案例12】基于vivado核的复数乘法器设计与实现
- [practice] mathematics in lottery
- 2.13 weekly report
- RT thread -- FTP of LwIP (2)
- [meisai] meisai thesis reference template
- Serial port-rs232-rs485-ttl
- BUAA计算器(表达式计算-表达式树实现)
- JS Vanke banner rotation chart JS special effect
- Take you to wechat applet development in 3 minutes
- Map sorts according to the key value (ascending plus descending)
猜你喜欢
Pointer written test questions ~ approaching Dachang
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
Blue Bridge Cup - day of week
Facebook and other large companies have leaked more than one billion user data, and it is time to pay attention to did
2.1 rtthread pin设备详解
C language -- structs, unions, enumerations, and custom types
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
Pointer for in-depth analysis (problem solution)
施努卡:3d视觉检测应用行业 机器视觉3d检测
[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
随机推荐
Mathematical modeling regression analysis relationship between variables
【SLAM】ORB-SLAM3解析——跟踪Track()(3)
[matlab] - draw a five-star red flag
Prime Protocol宣布在Moonbeam上的跨链互连应用程序
SAP ALV cell level set color
简易博客系统
Take you to wechat applet development in 3 minutes
[meisai] meisai thesis reference template
Map sorts according to the key value (ascending plus descending)
C#(三十一)之自定义事件
Align items and align content in flex layout
Python implementation of maddpg - (1) openai maddpg environment configuration
[Massey] Massey font format and typesetting requirements
Alibaba testers use UI automated testing to achieve element positioning
遥感图像超分辨重建综述
Pytorch基础——(2)张量(tensor)的数学运算
Pytorch基础——(1)张量(tensor)的初始化
Yyds dry inventory what is test driven development
The solution of permission denied (750 permissions should be used with caution)
3.2 detailed explanation of rtthread serial port device (V2)