Autor Beitrag
iltschii
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Do 19.06.03 19:36 
Hallo Leute!

In meinem SG 1 sind verschiedene Einträge enthalten. In Spalte 1 möchte ich auf eine beliebige Zelle klicken und dann soll das was da drin steht in ein anderes StringGrid übernommen werden. Wie stelle ich das an???


Vielen Dank schonmal,

Gruß iltschii
yukon-troll
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 60



BeitragVerfasst: Fr 20.06.03 08:03 
Hallo,

im Ereignis OnClick des StringGrid:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.SG1Click(Sender: TObject);
begin
  SG2.Cells[SG1.Col, SG1.Row] := SG1.Cells[SG1.Col, SG1.Row];
end;


willst du es auf die erste Spalte beschränken
(ist abhängig von der Anzahl fester Spalten) dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.SG1Click(Sender: TObject);
begin
  if SG1.Col = SG1.FixedCols then
    SG2.Cells[SG1.Col, SG1.Row] := SG1.Cells[SG1.Col, SG1.Row];
end;


MfG yukon-troll
Hoda
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Fr 20.06.03 08:59 
Hi iltschii,
mein Vorschlag ist:
str1 = Global String Variable

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
 IF StringGrid1.Cells[aCol,aRow] <> '' then
    str1 := StringGrid1.Cells[ACol,ARow]
 else begin
   StringGrid1.Cells[aCol,aRow] := str1;
   str1 := '';
 end;
end;


Somit ist es möglich, aus einer Zelle die gefüllt ist in eine leere Zelle zu einfügen. Wenn man will kann die Abfrage so gestaltet werden, dass auch gefüllte Zellen überschrieben werden.

Gruß,
hoda
yukon-troll
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 60



BeitragVerfasst: Fr 20.06.03 09:20 
@Hoda

das Ereignis SelectCell wird aber auch ausgelöst
wenn ich mich mit den Cursor-Tasten auf eine Zelle bewege,
iltschii fragte nach einem Klick auf die Zelle und der Inhalt der Zelle
sollte in ein anderes String-Grid übernommen werden.
Inhalt übernehmen bedeutet auch, einen leeren String übernehmen
und somit den Eintrag des anderen String-Grid aktualisieren
falls er einen abweichenden Eintrag enthält.

MfG yukon-troll
Hoda
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Mo 23.06.03 12:40 
Hi yukon-troll,
iltschii schrieb:
Zitat:
In Spalte 1 möchte ich auf eine beliebige Zelle klicken und dann soll das was da drin steht in ein anderes StringGrid übernommen werden.


Das passiert auch in meinem Beispiel Code. Wie das Gesamte Konzept von iltschii aus sieht kann nur iltschii wissen!

Ich persönlich würde anstelle von OnClick Event den StringGrid1SelectCell Event nehmen (was ich oben zu sehen ist), denn dort bekomme ich mehr Informationen als bei OnClick Event...

Gruß,
hoda