Board index » cppbuilder » TListView; How do I achieve column span?

TListView; How do I achieve column span?


2006-03-07 05:35:17 PM
cppbuilder59
Hello.
Is it possible to span columns in a TListView.
For example, how do I achieve the following:
1. First row to have 3 columns
2. Second row to have 1 column
3. Third row to have 2 columns
Please assist.
Regards,
PK
 
 

Re:TListView; How do I achieve column span?

At 10:35:17, 07.03.2006, PK wrote:
Quote

Hello.
Is it possible to span columns in a TListView.
For example, how do I achieve the following:
1. First row to have 3 columns
2. Second row to have 1 column
3. Third row to have 2 columns
AFAIK, no.
--
Rudy Velthuis [TeamB] rvelthuis.de/
"Obstacles are those frightful things you see when you take your eyes off
your goal."
- Henry Ford (1863-1947)
 

Re:TListView; How do I achieve column span?

"PK" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible to span columns in a TListView.
No.
If you use a TStringGrid, you can custom-draw the grid, erasing the grid
lines between cells and then drawing your own lines. You won't have true
columns by doing that, so you will have to manually keep track of which true
cells contains which virtual column cells, but you can mimic the appearance
of column spanning that way. It is not a trivial thing to implement,
though, so be prepared for a lot of extra work on your part.
Otherwise, you will have to find a third-party component that supports whant
you need.
Gambit
 

{smallsort}

Re:TListView; How do I achieve column span?

Thanks,
Does u have any third party components in mind?
PK
 

Re:TListView; How do I achieve column span?

"PK" < XXXX@XXXXX.COM >wrote in message
Quote
Does u have any third party components in mind?
No. You will just have to look around.
Gambit
 

Re:TListView; How do I achieve column span?

PK wrote:
Quote

Thanks,
Does u have any third party components in mind?

PK
Have a look at the Virtual Treeview. It is free to use.
www.delphi-gems.com/VirtualTreeview/VT.php
Stuart
--
 

Re:TListView; How do I achieve column span?

"Stuart Kelly" < XXXX@XXXXX.COM >wrote:
Quote

Have a look at the Virtual Treeview.
He want's a ListView - not a TreeView. In addition, that
doesn't support column spanning.
~ JD
 

Re:TListView; How do I achieve column span?

"PK" < XXXX@XXXXX.COM >wrote:
Quote

Is it possible to span columns in a TListView. [...]
Yes it is but it's *alot* of work and just not worth it unless
you absolutely must use a TListView. Use a TStringGrid instead
as Gambit suggested.
Set it's DefaultDrawing property to false and add an OnDrawCell
event. The event's parameters include ACol, ARow and ARect
which is all you need to know to do the spanning. For example:
TRect R = ARect;
switch( ARow % 3 )
{
case 0: // third row - 2 columns
if( ACol == 1 )
{
// set R.left & R.right to left half of grid
}
else if( ACol == 2 )
{
// set the to the right half of the grid
}
pGrid->Canvas->FillRect( R );
if( ACol == 1 )
{
// draw the text for ACol = 1
}
else
{
// draw the text for ACol = 2
}
break;
case 1: // first row - 3 columns
// set the grid to have 3 columns and do nothing to the rect
pGrid->Canvas->FillRect( R );
// draw the text for ACol
break;
case 2: // second row - one column
// set R.left and R.right to span entire grid
pGrid->Canvas->FillRect( R );
// draw the text for ACol = 1
break;
}
You'll also want to add some drawing at the end to frame
the newly drawn cell and you might need to set some Canvas
properties prior to FillRect to indicate a selected item.
~ JD