![]() |
DBCheckBox
Hallo
ich habe in meinem stringgrid checkboxen eingefügt, mein problem besteht darin das wenn ich eine checkbox checken möchte und diese auch checke verschwindet aus der anderen checkbox der hacken. so habe ich die checkbox ins grid gelegt.
Delphi-Quellcode:
procedure TForm1.DBGridLoginColExit(Sender: TObject);
begin if DBGridLogin.SelectedField.FieldName = DBCheckBox1.DataField then DBCheckBox1.Visible := True; end; //*********************************************************************************/ procedure TForm1.DBGridLoginDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); const IsChecked : array[Boolean] of Integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED); var DrawState: Integer; DrawRect: TRect; begin if (gdFocused in State) then begin if (Column.Field.FieldName = DBCheckBox1.DataField) then begin DBCheckBox1.Left := Rect.Left + DBGridLogin.Left + 2; DBCheckBox1.Top := Rect.Top + DBGridLogin.top + 2; DBCheckBox1.Width := Rect.Right - Rect.Left; DBCheckBox1.Height := Rect.Bottom - Rect.Top; DBCheckBox1.Visible := True; end end else begin if (Column.Field.FieldName = DBCheckBox1.DataField) then begin DrawRect:=Rect; InflateRect(DrawRect,-1,-1); DrawState := ISChecked[Column.Field.AsBoolean]; DBGridLogin.Canvas.FillRect(Rect); DrawFrameControl(DBGridLogin.Canvas.Handle, DrawRect, DFC_BUTTON, DrawState); end; end; end; //*********************************************************************************/ procedure TForm1.DBGridLoginKeyPress(Sender: TObject; var Key: Char); begin if (key = Chr(9)) then Exit; if (DBGridLogin.SelectedField.FieldName = DBCheckBox1.DataField) then Begin DBCheckBox1.SetFocus; SendMessage(DBCheckBox1.Handle, WM_Char, word(key), 0); End; end; //*********************************************************************************/ procedure TForm1.FormCreate(Sender: TObject); begin DBCheckBox1.DataSource := DS_Login; DBCheckBox1.DataField := 'NAME'; DBCheckBox1.Visible := False; DBCheckBox1.Color := DBGridLogin.Color; DBCheckBox1.Caption := ''; so meine frage : wie schaffe ich es alle checkboxen anzuklicken ohne das bei einer anderen der hacken wegfällt? |
Dieses Thema wurde am "27. Aug 2015, 09:49 Uhr" von "mkinzler" aus dem Forum "Neuen Beitrag zur Code-Library hinzufügen" in das Forum "Library: VCL / WinForms / Controls" verschoben.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz