Q&A

  • 체크박스 저장하는 방법
여러개의 체크박스중 선택된 체크박스들을 한개의 필드에 저장하는 방법을 모르겠습니다. 디비는 파라독스, 테이블을 사용합니다. 답변 부탁드립니다.

2  COMMENTS
  • Profile
    나그네 2001.10.08 21:08
    1.필드를 스트링형(파라독스에서는 A 타입)으로 합니다. 길이는 체크박스의 갯수에 따라 결정합니다. 체크박스를 5개로 하였으므로 5바이트로 합니다.

    2. 체크박스의 순서대로 Tag 를 부여합니다. 1부터 5까지로 합니다.

    3. 데이타는 01001,10111,11001 형식으로 저장되어 있습니다.

    4. 불러오기 :

    st:=table1.FieldByName('cb').asString;

    for cnt:=0 to ComponentCount-1 do

    if (Components[cnt] is TCheckBox) then

    for col:=1 to 5 do

    if st[col]='1' then begin

    if TCheckBox(Components[cnt]).Tag=col then

    TCheckBox(Components[cnt]).Checked:=true

    end

    else

    if TCheckBox(Components[cnt]).Tag=col then

    TCheckBox(Components[cnt]).Checked:=false

    5. 저장하기

    st:=' ';

    for cnt:=0 to ComponentCount-1 do

    if (Components[cnt] is TCheckBox) then

    if TCheckBox(Components[cnt]).Checked then

    st[TCheckBox(Components[cnt]).Tag]:='1'

    else

    st[TCheckBox(Components[cnt]).Tag]:='0';





    델초보 wrote:

    > 여러개의 체크박스중 선택된 체크박스들을 한개의 필드에 저장하는 방법을 모르겠습니다. 디비는 파라독스, 테이블을 사용합니다. 답변 부탁드립니다.

  • Profile
    irookie 2001.10.08 20:26
    이런 방법이 있을 수 있겠죠

    var

    str : string;



    str := '';



    if CheckBox1.Checked then

    str := str + CheckBox1.Caption + '구분자';



    if CheckBox1.Checked then

    str := str + CheckBox2.Caption + '구분자';

    ...



    이런 식으로 하고 str을 필드에 저장하면 되겠죠? ^^;;



    그럼,



    i believe i can fly~~



    --------



    델초보 wrote:

    > 여러개의 체크박스중 선택된 체크박스들을 한개의 필드에 저장하는 방법을 모르겠습니다. 디비는 파라독스, 테이블을 사용합니다. 답변 부탁드립니다.