Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TlistviewItem and  Alignment

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

688 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