Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TlistviewItem and  Alignment

Posted on 1998-07-10
2
Medium Priority
?
336 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 40 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

963 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