hennep
Programmer
- Dec 10, 2000
- 429
How can I address a label on a form by its name ( instead of addressing by an index).
I have a form with 256 labels. I tried the code below but cbuilder cannot handle: Controls["name"];
void Refresh( void ) {
static unsigned short int iLabel = 0;
TLabel *c;
char buf1[12], buf2[12];
if( ++iLabel >= 256 ) {
iLabel = 0;
}
sprintf( buf1, "lblByte%02X", iLabel );
sprintf( buf2, "%02X", P->Value(iLabel) );
c = (TLabel*)this->Controls[buf1];
c->Caption = buf2;
}
I have a form with 256 labels. I tried the code below but cbuilder cannot handle: Controls["name"];
void Refresh( void ) {
static unsigned short int iLabel = 0;
TLabel *c;
char buf1[12], buf2[12];
if( ++iLabel >= 256 ) {
iLabel = 0;
}
sprintf( buf1, "lblByte%02X", iLabel );
sprintf( buf2, "%02X", P->Value(iLabel) );
c = (TLabel*)this->Controls[buf1];
c->Caption = buf2;
}