Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Looking to Write multiple arguments into Rich text box at once.

Example
<pre lang="midl">this->databox->AppendText("\r\n");
                         this->databox->AppendText("Keyword is  ");
                         this->databox->AppendText((SD));
                         this->databox->AppendText("    ");
                         this->databox->AppendText("dt is  ");
                         this->databox->AppendText(SD1)




Would be something like this instead
this->databox->AppendText("\r\n Keyword is   {0}   dt is  {1}  ,SD,SD1)


This syntax if for StreamWriter,

Is there a way to do this when writing to a textbox??

Thanks for the help
Posted

What you want is String.Format(...)[^]. Works in all .NET versions (Link is to 1.1).

C#
this->databox->AppendText(String.Format("\r\n Keyword is   {0}   dt is  {1}"  ,SD,SD1));



Best Regards,

-MRB
 
Share this answer
 
v3
Comments
Rick Shaub 29-Apr-11 11:29am    
My 5. Also, you could use the "+" operator.
Member 7796364 29-Apr-11 11:56am    
Thanks for the answers here, Had to use String::Format, will keep the plus operator in my mind too.
Manfred Rudolf Bihy 2-May-11 6:30am    
String::Format is the C++/CLI sort of notation, sorry that I messed that up :). I would advise not to use + operator to concatenate the strings as it makes it hard when trying to internationalize your application. Using String::Format would take one string whereas the + operator would take more than one and most importantly in the format expression you can shift aorund the place holders to make the generated sentence conform to the grammar of the current language.
Alternatively, you could use the "+" operator:
this->databox->AppendText("\r\n Keyword is   " + SD + "   dt is  " + SD1);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900