c++builder - Why can't I access the width of a THeaderSection -
i'm trying use width of headersection in theadercontrol in c++ builder xe. theadercontrol called "header" tstringgrid i'm trying align widths called "grid". in onresize event handler header, i've got following code :
void __fastcall tmainform::headerresize(tobject *sender) { (int col=0; col<header->sections->count; col++) { grid->colwidths[col]=header->sections[0].width; } } which thought ok, won't compile.
can't seem find out how access widths of header.
also, when stuff in here compile (e.g. grid->colwidths[col]=100), headerresize event handler doesn't called (i.e. if put breakpoint in loop, run program , resize header, doesn't breakpoint).
you not accessing individual headers sections correctly. need instead:
void __fastcall tmainform::headerresize(tobject *sender) { (int col=0; col<header->sections->count; col++) { grid->colwidths[col] = header->sections->items[col]->width; } } notice sections[col] replaced sections->items[col], , .width replaced ->width.
as onresize event not being triggered, onresize triggered when entire theadercontrol resized. when resizing individual sections, onsectionresize event triggered instead. event tells section resized, eg:
void __fastcall tmainform::headersectionresize(tcustomheadercontrol *headercontrol, theadersection *section) { grid->colwidths[section->index] = section->width; }
Comments
Post a Comment