C# mobile CheckBox ImageList例子
想上传图片和代码,可是出错了.晕.需要的朋友直接向我索取QFord@qq.com,自发布起三个月内有效
1
using System;2
using System.Linq;3
using System.Collections.Generic;4
using System.ComponentModel;5
using System.Data;6
using System.Drawing;7
using System.Text;8
using System.Windows.Forms;9

10
namespace CheckBox11


{12
public partial class Form1 : Form13

{14
public Form1()15

{16
InitializeComponent();17
}18
public static int checkBoxIndex;19

20
private void cbMain_CheckStateChanged(object sender, EventArgs e)21

{22
bool isIndeterminate = cbMain.CheckState == CheckState.Checked;23
setIndeterminate(checkBox2, isIndeterminate);24
setIndeterminate(checkBox3, isIndeterminate);25
setIndeterminate(checkBox4, isIndeterminate);26
setIndeterminate(checkBox5, isIndeterminate);27
setIndeterminate(checkBox6, isIndeterminate);28
setIndeterminate(checkBox7, isIndeterminate);29

30
}31
private void setIndeterminate(System .Windows .Forms .CheckBox cb, bool isInteterminate)32

{33
if (isInteterminate)34

{35
cb.AutoCheck = true;36
cb.CheckState = CheckState.Indeterminate;37
}38
else39

{40
cb.AutoCheck = false;41
cb.CheckState = CheckState.Indeterminate;42
}43
}44

45
private void checkBox2_CheckStateChanged(object sender, EventArgs e)46

{47
if (checkBox2.CheckState == CheckState.Checked)48

{49
checkBoxIndex = 0;50
new frmPhoto().Show();51
}52
}53

54
private void checkBox3_CheckStateChanged(object sender, EventArgs e)55

{56
if (checkBox3.CheckState == CheckState.Checked)57

{58
checkBoxIndex = 1;59
new frmPhoto().Show();60
}61
}62

63
private void checkBox5_CheckStateChanged(object sender, EventArgs e)64

{65
if (checkBox5.CheckState == CheckState.Checked)66

{67
checkBoxIndex = 2;68
new frmPhoto().Show();69
}70
}71

72
private void checkBox4_CheckStateChanged(object sender, EventArgs e)73

{74
if (checkBox4.CheckState == CheckState.Checked)75

{76
checkBoxIndex = 3;77
new frmPhoto().Show();78
}79
}80

81
private void checkBox7_CheckStateChanged(object sender, EventArgs e)82

{83
if (checkBox7.CheckState == CheckState.Checked)84

{85
checkBoxIndex = 4;86
new frmPhoto().Show();87
}88
}89

90
private void checkBox6_CheckStateChanged(object sender, EventArgs e)91

{92
if (checkBox6.CheckState == CheckState.Checked)93

{94
checkBoxIndex = 5;95
new frmPhoto().Show();96
}97
}98
}99
}
1
using System;2
using System.Linq;3
using System.Collections.Generic;4
using System.ComponentModel;5
using System.Data;6
using System.Drawing;7
using System.Text;8
using System.Windows.Forms;9

10
namespace CheckBox11


{12
public partial class frmPhoto : Form13

{14
public frmPhoto()15

{16
InitializeComponent();17
}18

19
private void frmPhoto_Load(object sender, EventArgs e)20

{21
imageList1.ImageSize = new Size(240, 320);22
pbPhoto.Image = imageList1.Images[Form1.checkBoxIndex];23
}24

25
private void menuItem1_Click(object sender, EventArgs e)26

{27
this.Close();28
}29
}30
}

浙公网安备 33010602011771号