Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 15.12.08 17:44 
Hi, Delpher,

ja, ich weiß, ein Thread von mir ist noch offen, habe ich nicht vergessen, aber etwas ist wichtiger:

Wie kann ich eine Stringgrid-Spalte durch anklicken selecten?
Habe es so versucht, geht so aber nicht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.tntstringgrid3SelectCell(Sender: TObject; Col, Row: Longint; var CanSelect: Boolean);
var n : integer;
begin
  edit16.text := inttostr(row); edit17.text := inttostr(col-2);
  if row = 0 then
    for n := 1 to tntstringgrid3.RowCount-1 do tntstringgrid3.Cells[col,n] := selected;
end;


Ich habe auch nichts darüber gefunden. Wer kann helfen?

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Zorro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win 2000, Win XP Pro
Delphi 7 Architect
BeitragVerfasst: Mo 15.12.08 18:15 
Das Selektieren von Zellen im Stringgrid ist ja kein Problem - das tust du doch, sonst würde deine Ereignisroutine ja gar nicht aufgerufen werden.
Vermutlich stellt das Selektieren per Code das Problem dar.
Schau dir die Eigenschaft Selection des TStringgrid-Objektes an.

Greetz
Zorro

_________________
Real programmers confuse Xmas and Halloween because DEC 25 = OCT 31
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 15.12.08 18:31 
Hi, Zorro,
genau so ist es, ich habe jetzt folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if row = 0 then
  begin
    sel_rect.Left := col; sel_rect.Right := col;
    sel_rect.top := 1;    sel_rect.Bottom := tntstringgrid3.RowCount-1;
    tntstringgrid3.Selection := sel_rect;
  end;


Leider funzt er nicht. Was ist falsch??

Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 15.12.08 18:59 
Hallo,

im falschen Event?

Ich realisiere das so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var c,r : Integer;
begin
  StringGrid1.MouseToCell(X,Y,c,r);
  if r = 0 then
    StringGrid1.Selection := TGridRect(Rect(c,1,c,StringGrid1.RowCount-1));
end;


Funktioniert auch mit FixedRows.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 15.12.08 19:44 
Hi, Lannes - voll der Bringer-Code!!
(zu deutsch: ja, das ist genau, was ich gesucht habe)
Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas