Dbgird checkbox eklemek istiyorum Delphi Turkiye offline indirdim orada ipuçlarında dbgird e chechkbox eklemeyi buldum yalnız "TBWorking" bu komut yüzünden çalışmadı.Unit olarak googla ve sitede arattırmama rağmen bişi bulamadım yardımcı olursanız sevinirim.Kodlar aşşağıdagi gibi
Kod: Tümünü seç
dbGrid'e checkBox eklemek
1. Forma bir TcheckBox bileşeni koyun ve visible'ını False yap. Verdiğim kodda TcheckBox'ın ismi : Dbck
2. DBGrid1DrawColumnCell olayını aşağıdaki gibi ayarlayın.
3. DBGrid1ColExit olayını aşağıdaki gibi ayarlayın.
4. DBCheck.Click olayını aşağıdaki gibi ayarlayın.
procedure Tform1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
If (gdFocused in State) then
begin
// EXPRECORD is the name of the field to apply checkbox to
If(Uppercase(Trim(Column.FieldName)) = 'EXPRECORD' ) Then
begin
DBCk.Visible:=True;
DBCk.SetBounds(Rect.Left + DBGrid1.Left + 1,
Rect.Top + DBGrid1.Top + 1,
Rect.Right -Rect.Left,
Rect.Bottom - Rect.Top);
DBCk.Checked:=TBWorkingExpRecord.Value;
end;
end;
procedure Tform1.DBGrid1ColExit(Sender: TObject);
begin
DBCk.Visible:=False;
end;
procedure Tform1.DBCkClick(Sender: TObject);
begin
// Set field value in table equivalent to the check
// We used TCheckbox instead of TDBCheckbox due to null
// value handling
Try
TBWorking.Edit;
TBWorkingExpRecord.Value:=DBCk.Checked;
TBWorking.Post;
Except
On E:EDatabaseError do Showmessage(E.Message);
End;
end;