Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi StringGrid -> goEditing = FALSE -> Eine Spalte editierbar (https://www.delphipraxis.net/170624-stringgrid-goediting-%3D-false-eine-spalte-editierbar.html)

HolgerCW 26. Sep 2012 09:23

Delphi-Version: 2006

StringGrid -> goEditing = FALSE -> Eine Spalte editierbar
 
Hallo zusammen,

ich möchte in einem StringGrid nur eine Spalte editierbar machen. goEditing habe ich auf FALSE gelassen und wollte in onSelectCell folgendes tuen:

Code:
With Sender as TStringGrid do
begin

   
    If ACol = 6 then
    begin

     CanSelect := True;
     exit;
     
    end;

  end;
Klappt aber nicht ...

Helmi 26. Sep 2012 09:34

AW: StringGrid -> goEditing = FALSE -> Eine Spalte editierbar
 
Hallo,

ich hab das mal so gelöst:

Delphi-Quellcode:
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
  StringGrid: TStringGrid;

begin
  //temporäres StringGrid
  StringGrid := Sender as TStringGrid;

  //Zellen-Editor ausschalten
  StringGrid.Options := StringGrid.Options - [goEditing];

  If ARow > 0 then
    //2. und 3. Spalte editierbar
    If ACol in [1, 2] then
      begin
        //Zellen-Editor einschalten
        StringGrid.Options := StringGrid.Options + [goEditing];
      end;
end;
In diesem Beispiel sind die 2. und 3. Spalte editierbar - das musst du dann an deine Wünsche anpassen.

Nebenbei bemerkt: "Klappt aber nicht" ist wie "Geht nicht" keine Fehlermeldung!

HolgerCW 26. Sep 2012 09:49

AW: StringGrid -> goEditing = FALSE -> Eine Spalte editierbar
 
Vielen dank. Klappt gut.


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz