【发布时间】:2015-07-22 07:21:02
【问题描述】:
如何实现这个案例: 我有包含 20 个项目的 CheckListBox:症状 1、症状 2、..、症状 20。用户可以选择多个症状。让我感到困惑的是,如何为每个症状赋予多个值。这是我的代码:
for i := 0 to CheckListBox1.Items.Count - 1 do
begin
if CheckListBox1.Checked[i] = True then
begin
Memo1.Lines.Append(CheckListBox1.Items.Strings[i]);
if i = 0
p1 := 'Disease 1';
p2 := 'Disease 2';
p3 := 'Disease 3';
if i = 1 then
p1 := 'Disease 2';
if i = 2 then
p1 := 'Disease 1';
if i = 3 then
p1 := 'Disease 3';
if i = 4 then
p1 := 'Disease 2';
p2 := 'Disease 3';
if i = 5 then
p1 := 'Disease 1';
p2 := 'Disease 5';
p3 := 'Disease 6';
if i = 6 then
p1 := 'Disease 5';
Memo1.Lines.Add('Disease:' + p1+', '+p2+', '+p3);
Memo1.Lines.Add('');
end;
end;
end;
但结果并不如我所料。如何动态地制作 p1,p2,p3 ?
这是我在索引 2、4、6 处检查时的结果:
Symptomp 3
Disease:Disease 1, Disease 5, Disease 6
Symptomp 5
Disease:Disease 2, Disease 5, Disease 6
Symptomp 7
Disease:Disease 5, Disease 5, Disease 6
【问题讨论】:
-
输出是代码定义的。你想发生什么?
-
我想创建一个数组来保存每个疾病的 p1,p2,p3 值。
-
不是很清楚,能不能举几个例子说明你想得到什么和实际得到什么?
-
@Marco 进行进一步处理,我需要根据检查的症状选择哪种疾病。我很困惑如何解释我的问题。 -_-
-
我不太清楚你想要什么
标签: delphi checkbox multiple-value