Board index » delphi » ListView Bug! Help!

ListView Bug! Help!

Hi! I found something very weird with Delphi  ListView  component :

    I wrote a procedure to resize the column width of a list view with
default values. The user click on a button and the  procedure is called.
The procedure's code look something like that :

procedure ResizeListView;
var
    i : byte;
begin
    for i := 0 to NbColumn -1 do
        fmMain.ListView.Column[i].Width := 100;
end;

... and it doesn't work.  Well, it works if the user manually resize the
column. (but he must resize it two times!!!)

    It's very strange... The ListView is in very standard format : no
image, and vsReport type.

                    Please, if you know something about this weird
problem, help me!

                                        Thank you very much!

 

Re:ListView Bug! Help!


Quote
cyna wrote in message <35A13C79.B118E...@generation.net>...
>Hi! I found something very weird with Delphi  ListView  component :

>    I wrote a procedure to resize the column width of a list view with
>default values. The user click on a button and the  procedure is called.
>The procedure's code look something like that :

>procedure ResizeListView;
>var
>    i : byte;
>begin
>    for i := 0 to NbColumn -1 do
>        fmMain.ListView.Column[i].Width := 100;
>end;

>... and it doesn't work.  Well, it works if the user manually resize the
>column. (but he must resize it two times!!!)

>    It's very strange... The ListView is in very standard format : no
>image, and vsReport type.

>                    Please, if you know something about this weird
>problem, help me!

>                                        Thank you very much!

Try this -

procedure ResizeListView;
var
  Counter: integer;
begin
     ListView.Visible := False;
     for Counter := 0 to ListView.Columns.Count - 1 do
     begin
          ListView.Columns.Items[Counter].Width := 100;
     end;
     ListView.Visible := True;
end;

Paul Mason
Micro{*word*143} Systems

Other Threads