Solved

TlistviewItem and  Alignment

Posted on 1998-07-10
2
327 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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