delphi - How do I make two controls each occupy half their parent's area? -


i have application has sidebar attached (tpanel --> alright), uses categorypanel (alclient) inside of it. categorypanel has 2 groups non aligned. share boundary of these 2 groups fill whole panel space in 50/50 ratio. unfortunately categorygroups not support alignment in designtime, forces me run application every time want test it. tried set each categorygroup height half of panel, displays scrollbars. (see picture 2)

how can align/share boundary in ratio of 50/50 properly?

image1 image2

according comments, want run code:

procedure tform1.updategroupheights; begin   if not categorypanel1.collapsed     categorypanel1.height := categorypanelgroup1.clientheight div 2;   if not categorypanel2.collapsed     categorypanel2.height := categorypanelgroup1.clientheight -       categorypanelgroup1.clientheight div 2; end; 

whenever changes wish affect layout of groups. think need call function following events:

  • the oncreate event of form.
  • the onresize event of tcategorypanelgroup.
  • the oncollapse , onexpand events of 2 category panels.

that looks bit weird though when 1 panel collapsed, , other expanded. i'd rejig code fill available space.

if not categorypanel1.collapsed   ;//nothing if categorypanel1.collapsed , not categorypanel2.collapsed   categorypanel2.height := categorypanelgroup1.clientheight-categorypanel1.height; if not categorypanel1.collapsed , categorypanel2.collapsed   categorypanel1.height := categorypanelgroup1.clientheight-categorypanel2.height; if not categorypanel1.collapsed , not categorypanel2.collapsed begin   categorypanel1.height := categorypanelgroup1.clientheight div 2;   categorypanel2.height := categorypanelgroup1.clientheight-categorypanel1.height; end; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -