Q&A

  • 스트링그리드에 체크박스
스트링 그리드에 체크박스를 올렸습니다.



문제는 키보드 스페이스로하면 체크가 돼는데 마우스로 하면 안돼네여...



procedure TscrapForm.CheckBoxMouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: integer);

begin

with TCheckBox(Sender) do

CheckBox := not Checked;

end;



procedure TscrapForm.CheckBoxKeyUp(Sender: TObject; var Key: Word;

Shift: TShiftState);

begin

if Key = VK_SPACE then

with TCheckBox(Sender) do

Checked := not Checked;

end;



procedure TForm1.FormCreate(Sender: TObject);

begin

for i:=1 to StringGrid1.rowcount-1 do

begin

StringGrid1.Objects[0,i] := TCheckBox.Create(StringGrid1);

with TCheckBox(StringGrid1.Objects[0,i])do

begin

OnKeyUp := CheckBoxKeyUp;

OnMouseUp := CheckBoxMouseUp;

Parent := StringGrid1;

BoundsRect := StringGrid1.CellRect(0,i);

Width := StringGrid1.ColWidths[0];

Height := StringGrid1.RowHeights[0];

Checked := false;

end;

end;

end;



어디가 잘못된거져? 답변 부탁드립니다.

0  COMMENTS