?
Solved

Customize TListView

Posted on 2003-03-05
6
Medium Priority
?
363 Views
Last Modified: 2010-04-04
Hi,

I use a TListView component to display some data (report style). How can I add the ability to customize it? I want the user to be able to rearrange columns and hide some others. Are there built in features of TListView or do I have to add them myself?



Regards
J
0
Comment
Question by:j42
6 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 8072003
Hi,

You can use OnColumnClick or OnColumnRightClick to hide a column. Example: when a user right-clicks on a certain column then it gets hidden (it can be restored later by resizing it either in code or manually):

procedure TForm1.ListView1ColumnRightClick(Sender: TObject;
  Column: TListColumn; Point: TPoint);
begin
  Column.Width := 0;
end;

Regards, Geo
0
 
LVL 2

Expert Comment

by:steve_hsk
ID: 8072678
Hi J ...

I'll keep it a lil shorter this time :-)

Depends on exactly what you trying to do. If you want to change the appearance of a particular item, column, or draw the whole view yourself to provide graphics and a complete custom look, then you can use these events :

OnDrawItem
-----
OnCustomDraw
OnCustomDrawItem
OnCustomDrawSubItem
-----
OnAdvancedCustomDraw
OnAdvancedCustomDrawItem
OnAdvancedCustomDrawSubItem

to draw on : listview1.Canvas ... DrawRect, FillRect, etc

(if you need examples [they are lengthy], let me know)

If you just want to be able to hide and show columns then as Geobul suggested, you can choose an appropriate event, and set the column.width = new_value appropriately.

Steve
0
 
LVL 2

Author Comment

by:j42
ID: 8074458
Hi Steve,
nice to hear from you. Did you read the posting of swift99 in my last question. I guess I annoyed him in some way...
> (if you need examples [they are lengthy], let me know)
Thanks for offering. I know how to do it myself, I just want to avoid reinventing the wheel.

Best of luck
J
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:steve_hsk
ID: 8074992
Hi J,

I'm not so sure you annoyed anyone ... everyone has a bad day from time to time ;-)

Speak to ya soon,
Steve
0
 
LVL 2

Author Comment

by:j42
ID: 8081562
Hi,

I am going to answer the question myself. However thanks for beeing helpful. I will split the points.
Points for geobul:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20541229.html
Points for Steve:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20541230.html


// Switch two columns
procedure TForm1.Button2Click(Sender: TObject);
const
  SOURCE = 2;
  DEST = 1;
begin
  ListView1.Columns[DEST].Index := SOURCE;
  ListView1.UpdateItems(0, ListView1.Items.Count - 1);
end;

// Remove column
procedure TForm1.Button3Click(Sender: TObject);
var
  i: integer;
const
  COL = 3;
begin
  ListView1.Columns[COL].Destroy;

  for i := 0 to (ListView1.Items.Count - 1) do
  begin
    ListView1.Items[i].SubItems.Delete(COL - 1);
  end;
end;



Regards
J
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8081826
PAQ'd and points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

621 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