Board index » cppbuilder » Problem with data sharing between form

Problem with data sharing between form


2005-03-18 10:53:37 PM
cppbuilder101
Hi...that's my problem:
I've 2 forms. In 1st one I create 2 StringList* object and I
fill them with some value. Now I would to use them to
"initilize" 2nd form's Listboxes as:
1st Form:
...
2ndForm->ImportedData=StringListContent...
...
2nd form's OnShow event... (modal form):
...
2ndform->ListBox1=this->ImportedData;
...
But I continue to have runtime errors like (Cannot assign a nil
to a TListBoxstrings)
Here below is the code I used for 2nd form:
private:
TStringList* FRequired;
TStringList* FImported;
public:
virtual __fastcall TDualListDlg(TComponent* AOwner);
__property TStringList* RequiredData =
{read=FRequired,write=FRequired};
__property TStringList* ImportedData =
{read=FImported,write=FImported};
I hope I was clear about my problem...
TiA,Giovanni
 
 

Re:Problem with data sharing between form

"Giovanni" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
Hi...that's my problem:

private:
TStringList* FRequired;
TStringList* FImported;
public:
virtual __fastcall TDualListDlg(TComponent* AOwner);
__property TStringList* RequiredData =
{read=FRequired,write=FRequired};
__property TStringList* ImportedData =
{read=FImported,write=FImported};
You didn't show any code to really see what was
going on but this is what your code should look like:
class TDualListDlg : public TForm
{
private:
TStrings* FRequired;
TStrings* FImported;
void __fastcall SetRequired( TStrings* Value );
void __fastcall SetImported( TStrings* Value );
public:
__fastcall TDualListDlg( TComponent* AOwner );
__fastcall ~TDualListDlg();
__property TStrings* RequiredData = { read = FRequired, write = SetRequired };
__property TStrings* ImportedData = { read = FImported, write = SetImported };
};
__fastcall TDualListDlg::TDualListDlg( TComponent* AOwner )
: TForm( AOwner, 0 )
{
FRequired = new TStringList();
FImported = new TStringList();
}
__fastcall TDualListDlg::~TDualListDlg()
{
delete (TStringList*) FRequired;
delete (TStringList*) FImported;
}
void __fastcall TDualListDlg::SetRequired( TStrings* Value )
{
if( Value != FRequired )
FRequired->Assign( Value );
}
void __fastcall TDualListDlg::SetImported( TStrings* Value )
{
if( Value != FImported )
FImported->Assign( Value );
}
Todd