I am trying to copy all my 160 text boxes into one line. Each Textbox holds 1 character.

private void Menu_Copy(System.Object sender, System.EventArgs e)
 {   
    if(textBox1.SelectionLength > 0)
        textBox1.Copy();
 }

Is this the same user as trippinz?

Anyway, in the hypothetical scenario that you have all the textboxes stored in a List<TextBox> structure, you could do something like this.

// using statement: using System.Collections.Generic;
            List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5 }; // etc.

            // using statement: using System.Linq;
            var query = from textBox in boxes
                        select textBox.Text;

            string combinedText = string.Join(string.Empty, query.ToArray());
Comments
Very good response

I am not the same person as trippinz, but I was trying to help him tough.

The error:

Error	1	The type or namespace name 'Office2007Black' does not exist in the namespace 'DevComponents.DotNetBar' (are you missing an assembly reference?)	C:\Users\USA GAM3R\Documents\Visual Studio 2008\Projects\XBL Bio Maker\XBL Bio Maker\Form1.cs	11	58	XBL Bio Maker

That (Office2007Black) looks like an application theme. I'm not all that well versed on that particular topic, but you should be able to comment out the line(s) referencing it and continue as planned. That, or obtain the appropriate files/DLL and establish the necessary reference.

That (Office2007Black) looks like an application theme. I'm not all that well versed on that particular topic, but you should be able to comment out the line(s) referencing it and continue as planned. That, or obtain the appropriate files/DLL and establish the necessary reference.

FIXED

Edited 6 Years Ago by GAME: Fixed it

Is this the same user as trippinz?

Anyway, in the hypothetical scenario that you have all the textboxes stored in a List<TextBox> structure, you could do something like this.

// using statement: using System.Collections.Generic;
            List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5 }; // etc.

            // using statement: using System.Linq;
            var query = from textBox in boxes
                        select textBox.Text;

            string combinedText = string.Join(string.Empty, query.ToArray());

This will work write? With textBoxX

var query = from textBoxX in boxes

select textBoxX.Text;

 

string combinedText = string.Join(string.Empty, query.ToArray());

I will just copy 1 text box if I get lucky, is there anything I'm doing wrong?

List<TextBox> boxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10, textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20, textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30, textBox31, textBox32, textBox33, textBox34, textBox35, textBox36, textBox37, textBox38, textBox39, textBox40, textBox41, textBox42, textBox43, textBox44, textBox45, textBox46, textBox47, textBox48, textBox49, textBox50, textBox51, textBox52, textBox53, textBox54, textBox55, textBox56, textBox57, textBox58, textBox59, textBox60, textBox61, textBox62, textBox63, textBox64, textBox65, textBox66, textBox67, textBox68, textBox69, textBox70, textBox71, textBox72, textBox73, textBox74, textBox75, textBox76, textBox77, textBox78, textBox79, textBox80, textBox81, textBox82, textBox83, textBox84, textBox85, textBox86, textBox87, textBox88, textBox89, textBox90, textBox91, textBox92, textBox93, textBox94, textBox95 ,textBox96 ,textBox97 ,textBox98 ,textBox99 ,textBox100 ,textBox101 ,textBox102 ,textBox103 ,textBox104 ,textBox105 ,textBox106 ,textBox107 ,textBox108 ,textBox109 ,textBox110,textBox111 ,textBox112 ,textBox113 ,textBox114 ,textBox115 ,textBox116,textBox117 ,textBox118 ,textBox119 ,textBox120 ,textBox121 ,textBox122 ,textBox123 ,textBox124 ,textBox125 ,textBox126 ,textBox127 ,textBox128 ,textBox129 ,textBox130 ,textBox131 ,textBox132 ,textBox133 ,textBox134 ,textBox135 ,textBox136 ,textBox137 ,textBox138 ,textBox139 ,textBox140 ,textBox141 ,textBox142 ,textBox143 ,textBox144 ,textBox145 ,textBox146 ,textBox147 ,textBox148 ,textBox149 ,textBox150 ,textBox151 ,textBox152 ,textBox153 ,textBox154 ,textBox155 ,textBox156 ,textBox157 ,textBox158 ,textBox159 ,textBox160 ,textBox161 ,textBox162 ,textBox163 ,textBox164 ,textBox165 ,textBox166 ,textBox167 ,textBox168 ,textBox169 ,textBox170};
            
var query = from textBoxX in boxes

select textBoxX.Text;

Edited 6 Years Ago by GAME: n/a

Go back to your last thread. Look at the response Narue provided or the one I provided. Explicitly adding all those textboxes is just too much code compared to other options you have.

Go back to your last thread. Look at the response Narue provided or the one I provided. Explicitly adding all those textboxes is just too much code compared to other options you have.

Will do and also the thread that trippinz posted, I thought it was fixed but I wasnt.

This question has already been answered. Start a new discussion instead.