mercredi 22 juillet 2015

Multiple value in CheckListBox

How to implement this case: I have CheckListBox with 20 items: Symptomp 1, Symptomp 2,.., Symptomp 20. User can select more than one symptomp. Something that make me confuse is, how to give multiple value for each of symptomp. Here is my code:

  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;

But the result is not as i expected. How to make p1,p2,p3 dinamically ?

Here is the result when i check at index 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




Aucun commentaire:

Enregistrer un commentaire