如何动态创建数组文本框中存储文本框的文本值 [英] how to store text box's text value in array text box is dynamically created

查看:78
本文介绍了如何动态创建数组文本框中存储文本框的文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经动态创建了文本框.我能够从文本框检索文本值.如何在数组中存储此值?有可能吗?

代码:

i have created text box dynamically. i am able to retrieve text value from text box.how to store this value in array?? is it possible?

code:

foreach (Control c in panel1.Controls)
{


    if (c is TextBox)
    {
        TextBox txt = (TextBox)c;

        string msg = txt.Text;
        MessageBox.Show(msg);


    }

}

推荐答案

只需在适当的范围内定义一个数组,然后将文本框中的文本添加到其中即可. IE. YourArrayObject.Add(YourTextValue);
我强烈建议不要使用and Array [],而要使用List.
Just define an array in the appropriate scope and add the text from the textbox to it. ie. YourArrayObject.Add(YourTextValue);
I would highly suggest not using and Array[], but rather a List.


这篇关于如何动态创建数组文本框中存储文本框的文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆