呵呵,培训时老师讲的简单例子,俺自己作了一下,还可以运行。
QQ:5478740
MSN:
public Class ChinaRing1
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
1<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
2
3End Sub
4Protected WithEvents ChinaRingCkBox1 As System.Web.UI.WebControls.CheckBox
5Protected WithEvents ChinaRingCkBox2 As System.Web.UI.WebControls.CheckBox
6Protected WithEvents ChinaRingCkBox3 As System.Web.UI.WebControls.CheckBox
7Protected WithEvents ChinaRingCkBox4 As System.Web.UI.WebControls.CheckBox
8Protected WithEvents ChinaRingCkBox5 As System.Web.UI.WebControls.CheckBox
9Protected WithEvents ChinaRingCkBox6 As System.Web.UI.WebControls.CheckBox
10Protected WithEvents ChinaRingCkBox7 As System.Web.UI.WebControls.CheckBox
11Protected WithEvents ChinaRingCkBox8 As System.Web.UI.WebControls.CheckBox
12Protected WithEvents ChinaRingCkBox9 As System.Web.UI.WebControls.CheckBox
13Protected WithEvents ChinaRingLb1 As System.Web.UI.WebControls.Label
14Protected ChinaRingCkBox(8) As System.Web.UI.WebControls.CheckBox
15
16
17'注意: 以下占位符声明是 Web 窗体设计器所必需的。
18'不要删除或移动它。
19Private designerPlaceholderDeclaration As System.Object
20
21Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
22'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
23'不要使用代码编辑器修改它。
24InitializeComponent()
25End Sub
26
27#End Region
28
29
30Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
31ChinaRingCkBox(0) = ChinaRingCkBox1
32ChinaRingCkBox(1) = ChinaRingCkBox2
33ChinaRingCkBox(2) = ChinaRingCkBox3
34ChinaRingCkBox(3) = ChinaRingCkBox4
35ChinaRingCkBox(4) = ChinaRingCkBox5
36ChinaRingCkBox(5) = ChinaRingCkBox6
37ChinaRingCkBox(6) = ChinaRingCkBox7
38ChinaRingCkBox(7) = ChinaRingCkBox8
39ChinaRingCkBox(8) = ChinaRingCkBox9
40End Sub
41
42Private Sub ChinaRingCkBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox1.CheckedChanged
43ChinaRingCkBox_CheckedChanged(1, sender, e)
44End Sub
45
46Private Sub ChinaRingCkBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox2.CheckedChanged
47ChinaRingCkBox_CheckedChanged(2, sender, e)
48End Sub
49
50Private Sub ChinaRingCkBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox3.CheckedChanged
51ChinaRingCkBox_CheckedChanged(3, sender, e)
52End Sub
53
54Private Sub ChinaRingCkBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox4.CheckedChanged
55ChinaRingCkBox_CheckedChanged(4, sender, e)
56End Sub
57
58Private Sub ChinaRingCkBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox5.CheckedChanged
59ChinaRingCkBox_CheckedChanged(5, sender, e)
60End Sub
61
62Private Sub ChinaRingCkBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox6.CheckedChanged
63ChinaRingCkBox_CheckedChanged(6, sender, e)
64End Sub
65
66Private Sub ChinaRingCkBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox7.CheckedChanged
67ChinaRingCkBox_CheckedChanged(7, sender, e)
68End Sub
69
70Private Sub ChinaRingCkBox8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox8.CheckedChanged
71ChinaRingCkBox_CheckedChanged(8, sender, e)
72End Sub
73
74Private Sub ChinaRingCkBox9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChinaRingCkBox9.CheckedChanged
75ChinaRingCkBox_CheckedChanged(9, sender, e)
76End Sub
77
78Private Sub ChinaRingCkBox_CheckedChanged(ByVal index As Integer, ByVal sender As System.Object, ByVal e As System.EventArgs)
79Dim i As Integer
80i = 0
81Dim ChinaRingCk As Boolean = False
82If index = 1 Then
83ChinaRingCk = True
84Else
85If ChinaRingCkBox(index - 2).Checked Then
86ChinaRingCk = True
87End If
88Do While i < index - 2
89If ChinaRingCkBox(i).Checked Then
90ChinaRingCk = False
91End If
92i = i + 1
93Loop
94End If
95If Not ChinaRingCk Then
96ChinaRingCkBox(index - 1).Checked = Not ChinaRingCkBox(index - 1).Checked
97'可以在这里加一个提示,根据条件提示不能套入,或不能拿出该环。
98End If
99End Sub
100
101End Class</system.diagnostics.debuggerstepthrough()>