简体   繁体   中英

copy text from several textboxes to one specific textbox with linebreaks for each new text box

Forgive the long title!

I am just starting out learning C# as a hobby really to make simple programs in my spare time. I decided to make (what i thought would be a simple little program to log notes) I have searched for sample code on this to try and figure out how to implement it but cannot find exactly what i am looking for.

Here is what i need it to do.

I have 8 textboxes setup and 4 checkboxes setup. When a user types into textbox1 i need it to be typed into textbox 8 + Newline. Type in textbox2 it should go in textbox 8 as well with another Newline and so on and so on through textbox 7. If the user selects the checkboxes it will put a predetermined text into textbox8 with a space. All out put from every textbox/checkbox should go into textbox8.

I have tried notes_view_text.Text = cust_name_text.Text; in each of my textboxes(with the names changed obviously) and also tried Environment.NewLine and i can either get one textbox to type and then when i go to the next it clears my textbox 8 or it will go to another line on every keystroke.

I am sure i am missing something very simple that requires a very basic understanding of the language and for that i apologize. Also if this is more difficult then i thought please let me know and i will attempt in a different language or forget about it. I just wanted to create this to make logging notes and copying them to clipboard(know how to do that part heh) in my job easier.

要将文本添加到现有字符串中,请使用+ =代替=,例如

notes_view_text.Text += cust_name_text.Text + Environment.NewLine;

Please let me know if this helps:

void combine()
{
    box8.Text = box1.Text;
    box8.Text += Environment.NewLine;
    box8.Text += box2.Text
    box8.Text += Environment.NewLine;
    box8.Text += box3.Text
    box8.Text += Environment.NewLine;
    box8.Text += box4.Text
    box8.Text += Environment.NewLine;
    box8.Text += box5.Text
    box8.Text += Environment.NewLine;
    box8.Text += box6.Text
    box8.Text += Environment.NewLine;
    box8.Text += box7.Text
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM