Solved

TlistviewItem and  Alignment

Posted on 1998-07-10
2
325 Views
Last Modified: 2010-04-04
hi
i"m using the TlistView and in one of the TlistViewItems u need to make an alignment
 taRightJustify , 4 some reason (gess this is borland/imprise bug) it does let me to do it
and always going back to taLeftJustify
how can i fix it ?
10x inadvance
asi
0
Comment
Question by:asi
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
vladika earned 20 total points
ID: 1357573
Try it (simplest way)

1) copy comctrls.pas from source in your project directory
2) modify two procedures
procedure TListColumn.SetAlignment(Value: TAlignment);
procedure TCustomListView.UpdateColumn(Index: Integer);

procedure TListColumn.SetAlignment(Value: TAlignment);
begin
  if (Alignment <> Value) then  // here was ' and Index <> 0 '
  begin
    FAlignment := Value;
    Changed(False);
    TListColumns(Collection).Owner.Repaint;
  end;
end;

procedure TCustomListView.UpdateColumn(Index: Integer);
var
  Column: TLVColumn;
begin
  if HandleAllocated then
    with Column, Columns.Items[Index] do
    begin
      mask := LVCF_TEXT or LVCF_FMT;
      pszText := PChar(Caption);
 //     if Index <> 0 then
        case Alignment of
          taLeftJustify: fmt := LVCFMT_LEFT;
          taCenter: fmt := LVCFMT_CENTER;
          taRightJustify: fmt := LVCFMT_RIGHT;
        end;  // do not forget ;
//      else fmt := LVCFMT_LEFT;
      if WidthType > ColumnTextWidth then
      begin
        mask := mask or LVCF_WIDTH;
        cx := FWidth;
        ListView_SetColumn(Handle, Index, Column);
      end
      else begin
        ListView_SetColumn(Handle, Index, Column);
        if ViewStyle = vsList then
          ListView_SetColumnWidth(Handle, -1, WidthType)
        else if ViewStyle = vsReport then
          ListView_SetColumnWidth(Handle, Index, WidthType);
      end;
    end;
end;

3) in your program
procedure TForm1.FormCreate(Sender: TObject);
begin
  ListView1.Columns[0].Alignment := taRightJustify; // you cannot set it in design time
  // but now in runtime you can
end;

4) rebuild project (build, not compile)

5) run

0
 
LVL 3

Expert Comment

by:vladika
ID: 1357574
Did you found another way?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now