[英]can any one suggest how to pass a Dynamic list from one form to another?
Hi all can any one suggest how to pass a dynamic list which contains some elements which i want to display in second form on form 1 button click... 大家好,有人可以建议如何通过动态列表,其中包含一些要在表单1按钮单击时以第二种形式显示的元素...
AS some post are already there for this question but none of then are solved till now, can any one help me in this? 由于已经有此问题的帖子,但到现在为止都没有解决,有人可以帮助我吗?
I tried this way. 我尝试过这种方式。
public List<string> final_input
{
get { return final_input1; }
set { final_input1 = final_input; }
}
private void button1_Click_1(object sender, EventArgs e)
{
final_input = new List<string>(Class_Grid_opr.final_input_list.ToList());
Take_INput_form tcn = new Take_INput_form(this);
tcn.ShowDialog();
}
in second form i tried to use that list with the object of main form but unable to get elements of list its returning empty list.. 在第二种形式中,我尝试将该列表与主形式的对象一起使用,但无法获取列表中返回的空列表的元素。
In simple words one from has a list which has few elements i want to pass that list to from 2 on button click.... 用简单的话来说,一个来自一个具有很少元素的列表,我想在单击按钮时将该列表从2传递给...。
sorry for bad english ,please help me.. 对不起,英语不好,请帮我。
Add new property to the form and initialize it 向表单添加新属性并对其进行初始化
Take_INput_form tcn = new Take_INput_form(this);
tcn.FinalInput = final_input; // Add FinalInput property to Take_INput_form
tcn.ShowDialog();
i solved this probs below code worked for me.... 我解决了下面的代码对我有用的问题....
Take_INput_form tcn = new Take_INput_form(listname);
tcn.ShowDialog();
in form 2 during initilisation 在初始化过程中以表格2
public Take_INput_form(List<string > input)
{
InitializeComponent();
Final_input_display(input);
}
public void Final_input_display(List<string> temp)
{
for (int i = 0; i <temp.Count; i++)
{
dataGridView1.Rows.Add();
dataGridView1.Rows[i].Cells[0].Value = temp [i];
}
}
if any one has better solution than this please post... 如果有人有比这更好的解决方案,请发表...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.