-4
private void btnGravarNovosValores_Click_1(object sender, EventArgs e)
{
string descricao;
string textBoxX;
int i = 0;
foreach (Object texto in lstTabelaProdutosPreco.Items)
{
descricao = texto.ToString();
i++;
textBoxX = ("textBox" + i.ToString());
//MessageBox.Show(descricao + " " + textBox);
TabelaAlterarProdutosCalibresValores tabelaAlterarProdutosCalibresValores = new TabelaAlterarProdutosCalibresValores();
tabelaAlterarProdutosCalibresValores.idTabelaPrecos = Convert.ToInt32(lstNome.SelectedValue.ToString().Substring(0, 3));
tabelaAlterarProdutosCalibresValores.idProduto = Convert.ToInt32(descricao.ToString().Substring(0, 4));
tabelaAlterarProdutosCalibresValores.idCalibre = descricao.ToString().Substring(8, 5);
tabelaAlterarProdutosCalibresValores.precoVenda = double.Parse(textBoxX.ToString().Trim());
if (tabelaAlterarProdutosCalibresValores.UpDateDefault())
{
MessageBox.Show(lstNome.SelectedValue.ToString().Substring(0, 3) + descricao.ToString().Substring(0, 4) + descricao.ToString().Substring(8, 5) + textBoxX);
}
}
}
I didn’t understand. Could I talk a little more in the body of the question? Just the title and this code didn’t tell me much
– Jefferson Quesado
I can build Textbox names through a textbox cycle +i = textbox1, but I can’t use it as the name of the textbox tableAlteRodusCalibresValue = double. Parse(textBoxX.Tostring(). Trim());
– user9426886
"build the names" of textbox ?!?! try to be clearer young
– Rovann Linhalis
string Description; string textBoxX; int i = 0; foreach (Object text in lstTabelaProductsPreco.Items) { Description = text.Tostring(); i++; textBoxX = ("textbox" + i.Tostring()); }
– user9426886
You want to access a textbox that is in your form by entering its name in a string. This ?
– Rovann Linhalis
Welcome to Stackoverflow, to start make a [tour] and then see [Ask] and [Answer]. Always inform a minimal, complete and verifiable example
– Don't Panic
through the foreach cycle with you each turn get a description and build a textbox name. when I will use the textbox name
– user9426886
you are only asking the wrong question young, What you want is to access the Textbox on your screen dynamically, inside the loop. Ie by the string
"textBox"+i.ToString()
Voce wants access to control:string texto = textBox1.Text;
– Rovann Linhalis
if I try to use the name created daigual a textbox (textboxX) in a messagebox appears the correct name, if I try to use the same Textboxx to insert the contents of the textbox in a database, from the error "input string with incorrect format"
– user9426886
that’s it, how do I get the string recognized as a textbox
– user9426886
Sorry is the 1 time I am using this site and do not know how to ask the questions
– user9426886
no problems, see if my answer help and access the tour indicated by Everson
– Rovann Linhalis