Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change content of a TMemo item

Status
Not open for further replies.

BorlandDave

Programmer
Jun 13, 2005
86
GB
I know it is possible to change the value of a static label by:

Label1->Caption="Some text";

But how do you change the content of a TMemo item? Thanks for any help.

 
I just cut and pasted a function from a project of mine.
go to the help and peruse the methods and properties of
"TMemo".


Code:
void __fastcall TSqlBuild::Run1Click(TObject *Sender)
{
    //ShowMessage (Memo1->Text);
  
    char buff [1000];  // buffer for the query
    buff[0] = NULL;
    int x;

    // load query from memo. adding the space character at
    // the end of each line as needed to maintain the word space.
    x = Memo1->Lines->Count;
    for (int y = 0; y < x; y++)
    {
        strcat (buff, Memo1->Lines->Strings [y].c_str ());
        if ((buff [strlen (buff) - 1] != ' ') && (y < (x - 1)))
            strcat (buff, " ");
    }

    // declare the Query object and call.
    MHDBSQL *QUERY = new MHDBSQL;
    QUERY->Open (buff);

    Memo1->Lines->Add (" ");
    Memo1->Lines->Add (QUERY->FieldsStr);
    Memo1->Lines->Add (QUERY->TableName);
    Memo1->Lines->Add (QUERY->WhereStr);

    Memo1->Lines->Add (" ");
    for (x = 0; x < (signed)QUERY->Fields.size (); x++)
        Memo1->Lines->Add (QUERY->Fields [x].c_str ());

    Memo1->Lines->Add (" ");
    for (x = 0; x < (signed)QUERY->Where.size (); x++)
        Memo1->Lines->Add (QUERY->Where[x].c_str ());

    Memo1->Lines->Add (" ");
    Memo1->Lines->Add (QUERY->error.c_str ());

    Memo1->Lines->Add (" ");
    AnsiString a = "The Result count is ";
    Memo1->Lines->Add (a + QUERY->ResultCount);

    Memo1->Lines->Add (" ");
    Memo1->Lines->Add (QUERY->filename.c_str ());
                            
   delete QUERY;

    //Query ("select name, time, date from address.mtb where Address1 is baytown");
}

tomcruz.net
 
Memo1->Lines is a string list object so you can also use
the Memo1->Lines->Strings [] to change the memo contents.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top