Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Obtaining a TEdit component in execution time

zairillozairillo Member Posts: 1
Hi, I'm doing a project and I would need to obtain a TEdit component in execution time to personalize my responses to the component I want. I have created this code example but it appears an error in execution time (appearing the assembler code where the exception is thrown):

void insert_item(int value_to_insert,int refComponent){
char *nameTEdit ;
bool found = false ;
int i=0 ;
sprintf(nameTEdit,"TEdit%d",refComponent);
while (iComponentCount && !found){
TEdit *typeEdit(dynamic_cast(Form1->Components[i]));
char *name ;
strcpy(name,typeEdit->Name.c_str());
if(typeEdit && (strcmp(name,nameTEdit) == 0)){
found = true ;
typeEdit->Text= value_to_insert ;
}
i++ ;
}
}

This way, inside my Form1, I find which is the component corresponding with the one that could be named as "TEdit%d", due to the fact that all my components will be: TEdit1, TEdit2, TEdit3, ...

The execution time error appears in the line: "typeEdit->Text=value_to_insert"

Thanks a lot.
Sign In or Register to comment.