Autor Beitrag
Daniel L.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: So 29.01.06 19:18 
Hallo, hab nach stundenlanger Fehlersuche folgendes Phänomen entdeckt:

Ich erzeuge eine Instanz von TListView und setze ColumnClick und Visible auf false und den Parent aufs Hauptformular.
Jetzt erzeuge ich ein paar Spalten, wobei eine Spalte Width=0 hat.
Nun setze ich visible auf true.

So weit - so gut, aber:

Schalte ich ColomnClick auf true, werden alle Spalten hinter der mit Width=0 gelöscht !
Vertausche ich gar die Reihenfolge von 'visible := false' und 'parent := form1',
bekomme ich eine 'Stream Lesefehler Exception'.

Das Verhalten ergibt sich nur bei Visible und ColomnCclick (von false auf true).

Verständnissproblem oder Bug ?

Danke für Hilfe _Daniel L.

(Delphi 7)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
var
  Form1: TForm1;
  LV : TListView;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
   LV := TListView.create(nil);
   with LV do
      begin
        Visible := false;
        Parent := form1;
        ViewStyle := vsReport;
        ColumnClick := false;

        for i := 0 to 2 do
          begin
            Columns.Add;
            Columns[i].Width := 32;
            Columns[i].Caption := IntToStr (i);
          end;

        columns.add;
        columns[3].Width := 0;
        Columns[3].Caption := IntToStr (3);

        for i := 4 to 6 do
          begin
            Columns.Add;
            columns[i].Width := 32;
            Columns[i].Caption := IntToStr (i);
          end;

      visible := true;
      end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     LV.ColumnClick  := true;
end;
Daniel L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140
Erhaltene Danke: 14

W7, W8
TurboD Prof, Delphi Community
BeitragVerfasst: So 29.01.06 21:45 
P.S. :

Die Stream-Exception hat nichts damit zutun, sie entsteht ja schon beim compilieren.

Hab jetzt mal den Quelltext unter Delphi 2 laufen lassen, dort verhält sich nach "ColumnClick := true" alles wie erwartet
... ein Bug in D7 ?


_Daniel
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: So 29.01.06 21:54 
Hallo,

mit D3 gibt es auch keine Probleme.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )