Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to adjust the width of THeaderControl sections automatically, Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
when the first section is resized 26-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
95
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have THeaderControl with 4 sections. When I resize the first section, I need the 
remaining 3 sections to resize proportionally to their size to ensure that they 
don't go out of visibility (I mean that the last section end position always 
remains the same). I tried to use OnSectionResize or OnSectionTrack events, but 
without success. Can anyone help?

Answer:
1   
2   procedure TForm1.ResizeMyHeader();
3   const
4     MIN_COL_WIDTH = 10;
5   var
6     iColWidth: Integer;
7     iColExtra: Integer;
8     iSection: Integer;
9   begin
10    if HeaderControl1.Sections.Count > 1 then
11    begin
12      iColWidth := HeaderControl1.Width;
13      Dec(iColWidth, HeaderControl1.Sections[0].Width);
14      iColWidth := (iColWidth div (HeaderControl1.Sections.Count - 1));
15      iColExtra := HeaderControl1.Width - (HeaderControl1.Sections[0].Width +
16        (HeaderControl1.Sections.Count - 1) * iColWidth);
17      {resize the 2nd to the last columns}
18      if iColWidth >= MIN_COL_WIDTH then
19      begin
20        for iSection := 1 to HeaderControl1.Sections.Count - 2 do
21        begin
22          HeaderControl1.Sections[iSection].Width := iColWidth;
23        end;
24        HeaderControl1.Sections[HeaderControl1.Sections.Count - 1].Width := iColWidth 
25  + iColExtra;
26      end;
27    end;
28  end;
29  
30  procedure TForm1.HeaderControl1_OnSectionResize(HeaderControl: THeaderControl;
31    Section: THeaderSection);
32  begin
33    Self.ResizeMyHeader;
34  end;
35  
36  procedure TForm1.Form_OnResize(Sender: TObject);
37  begin
38    Self.ResizeMyHeader;
39  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC