Autor Beitrag
AlexII
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Do 29.11.07 21:38 
Hallo Jungs!

Wie prüfe ich, ob in einer StringGrid was geändert wurde? Muss das prüfen bevor das Formular schließe. Muss ja den Nutzer fragen, ob er die Änderungen speichern will oder nicht.

Danke!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 29.11.07 21:54 
Moin!

Das StringGrid ist dafür der falsche Ansatz. ;) Wenn du das Programm startest (bzw. eine Datei geöffnet hast) setzt du eine Variable Changed: Booleanauf FALSE. Immer, wenn du was an den Daten veränderst, setzt du Changedauf TRUE. Vor dem Programmende fragst du dann ab, ob Changed = TRUEist. Wenn ja -> Daten speichern. :idea: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
AlexII Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Do 29.11.07 22:02 
Zitat:
wenn du was an den Daten veränderst, setzt du Changed auf TRUE


Boh.... dann muss ich ja jeden Schritt überwachen, das ist ja viel zu kompliziert, geht das vllt einfacher?
Bei RichEdit wird das z.B. so geprüft: if RichEdit1.Modified then

Das muss ja einfacher gehen, oder?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 29.11.07 22:11 
Moin!

user profile iconAlexII hat folgendes geschrieben:
Boh.... dann muss ich ja jeden Schritt überwachen, das ist ja viel zu kompliziert, geht das vllt einfacher?
Bei RichEdit wird das z.B. so geprüft: if RichEdit1.Modified then
Was meinst du denn, wie die das intern in der Komponente wohl feststellen, ob da was geändert wurde... ;) Aber diese Eigenschafts gibt´s eben AFAIK nicht im StringGrid. :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
AlexII Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Do 29.11.07 23:40 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
const
  warnText = 'Änderungen speichern in %s?';
begin
  if RichEdit1.Modified then
  begin
    case MessageDlg(Format(warnText, [pfad]), mtConfirmation,
      [mbYes, mbNo, mbCancel], 0) of
      idYes: Speichern1Click(Self);
      idCancel: CanClose := False
    end
  end
end;



So ähnlich will ich fürs StringGrid haben.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 29.11.07 23:50 
:gruebel: rede ich so undeutlich?

user profile iconNarses hat folgendes geschrieben:
diese Eigenschafts gibt´s eben AFAIK nicht im StringGrid.
:nixweiss:

_________________
There are 10 types of people - those who understand binary and those who don´t.
AlexII Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Fr 30.11.07 00:00 
Stell dir vor der Nutzer ändert in der StringGrid die Zahl 12 auf 13, dann überlegt sich und macht das rückgängig. Beim Schließen des Programms muss dann keine abfrage nach Speichern kommen. Wie soll ich das anstellen? Das Programm kann ja nix auf True stellen, wenn es gar nicht weiß, ob das wieder eine 12 ist oder eine andere Zahl.

Das muss aber gehen, kenne das von anderen Programmen.

Mir reicht es eigentlich auch aus, wenn es geprüft wird, ob überhaupt am Programm was getan wurde oder man nur die Anträge angeguckt hat.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 30.11.07 00:06 
Moin!

user profile iconAlexII hat folgendes geschrieben:
Das muss aber gehen, kenne das von anderen Programmen.
Das habe ich ja auch nicht bestritten. ;) Es gibt aber eben keine Eigenschaft des TStringGrid, die dir diese Information zur Verfügung stellt. :|

user profile iconAlexII hat folgendes geschrieben:
Stell dir vor der Nutzer ändert in der StringGrid die Zahl 12 auf 13, dann überlegt sich und macht das rückgängig. Beim Schließen des Programms muss dann keine abfrage nach Speichern kommen. Wie soll ich das anstellen?
Für so eine Information könntest du am Anfang eine Prüfsumme über deine Daten erstellen und vor dem Ende erneut berechnen. Ist die Prüfsumme dann ungleich, hat der Benutzer was verändert. :idea:

user profile iconAlexII hat folgendes geschrieben:
Mir reicht es eigentlich auch aus, wenn es geprüft wird, ob überhaupt am Programm was getan wurde oder hat man nur die Anträge angeguckt.
Wie das geht, habe ich dir oben bereits gesagt. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
AlexII Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Fr 30.11.07 00:16 
Ok dann danke erst mal, ich versuchs, mal schuen! :-)