Solved

TlistviewItem and  Alignment

Posted on 1998-07-10
2
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 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