cxComboBox의 내용을 Code로 조회할때 사용하는 법

cxComboBox의 내용을 조회할때 값외에 코드나 기타 사항을 저장하기 위해 작업하는 내용입니다.

보여지는 값과 가져와야할 코드의 값을 따로 가져와야 할경우 유용하게 사용할듯 합니다.

type
  포인트레코드 = ^레코드;
  레코드 = record
    Code : String;
    name : String;
    data : Integer;
  end;

procedure TForm1.버튼넣기Click(Sender: TObject);
var
  p : 포인트레코드;
  I: Integer;
begin

  cxCheckComboBox1.Properties.Items.Clear;

  for I := 0 to 10 do
  begin
    New( p );
    p^.Code := IntToStr(i);
    p^.name := '김말동 - ' + IntToStr(i);
    p^.data := i;

    with cxCheckComboBox1.Properties.Items.Add do
    begin
      Description := p^.name;
      Tag := Integer( p );
    end;

  end;


end;

procedure TForm1.버튼_찾기Click(Sender: TObject);
var
  p : 포인트레코드;
  I: Integer;
begin

  ListBox1.Items.Clear;
  for I := 0 to cxCheckComboBox1.Properties.Items.Count - 1 do
  begin
    if cxCheckComboBox1.States[i] = cbsChecked then
    begin
      p := Pointer( cxCheckComboBox1.Properties.Items[i].Tag );
      ListBox1.Items.Add( P^.name );
    end;
  end;

end;

procedure TForm1.버튼_지우기Click(Sender: TObject);
var
  p : 포인트레코드;
  I: Integer;
begin

  for I := 10 downto 0 do
  begin
    p := Pointer( cxCheckComboBox1.Properties.Items[i].Tag );
    Dispose( p );
  end;

  cxCheckComboBox1.Properties.Items.Clear;

end;

Author: yyjksw