We help IT Professionals succeed at work.

How can I change the height of a listview header?

Peter Kiers
Peter Kiers asked
on
2,027 Views
Last Modified: 2012-05-10
Hi,

How can I change the height of a listview header?
I have searched on the internet, but didn't find anyting
that made sense.

Who can help me?

Peter Kiers
Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2011

Commented:
I have had similar issue long time ago. What I did is that I created two ListViews, one showing only the header on top of the other that has hidden header (see the attached pic).
In the Columns Editor I set the Minwidth, Maxwidth, and the Width of the columns of the Header ListView to be equivalent to the width of the second ListView columns to prevent the header columns of being re-sized so not to lose the columns' structure.

But if re-sizing the columns is necessary all you have to do is capturing the column resizing event at the Header ListView then re-size the other one to keep the respective columns in the same width.

To capture a column re-size event:
http://www.swissdelphicenter.ch/torry/showcode.php?id=1264

JG
Listview-e.g.bmp

Commented:
btw. I see now that I forgot to include the required uses clause... I think the example I provided requires CommCtrl, ComCtrls apart from the usual standard units. (can't try it right now)
Peter KiersOperator

Author

Commented:
I am trying HYPO's solution now, and i get a few errors:

  [Pascal Error] Main.pas(89): E2003 Undeclared identifier: '_HD_LAYOUT'
  [Pascal Error] Main.pas(94): E2003 Undeclared identifier: 'ListView_GetHeader'
  [Pascal Error] Main.pas(98): E2010 Incompatible types: 'TRect' and 'Pointer'
  [Pascal Error] Main.pas(101): E2003 Undeclared identifier: 'Header_Layout'

Is there something that I should declare at uses?

P.

Commented:
What version of Delphi do you use?
Peter KiersOperator

Author

Commented:
How can I call for this procedure and I want to change the height of the panels to 19.
Where in the code should I put 19.

Commented:
Yep, with Delphi 6, all I have to add is the CommCtrl unit to the uses clause... try that and it should work.

/Hypo
Peter KiersOperator

Author

Commented:
Borland Developer Studio 2006
Peter KiersOperator

Author

Commented:
CommCtrl works
Peter KiersOperator

Author

Commented:
How can I call for this procedure and I want to change the height of the panels to 19.
Where in the code should I put 19.

Commented:
I made a small example in a button... just setup a list view on your form, then add a button, and try it out...

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetListViewHeaderHeight(ListView1, 19 {HERE IS WHERE YOU PUT YOUR HEIGHT});
end;

I think you should be able to use it in one of the resize events... But I'll have to check if there are any issues with putting it there first...

/Hypo
Peter KiersOperator

Author

Commented:
Your solution works fine.

Greetings, Peter Kiers

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.