简体   繁体   English

有谁能建议如何将动态列表从一种形式传递到另一种形式?

[英]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.

相关问题 如何将2个变量从一种形式传递给另一种形式? - How can I pass 2 variables from one form to another? 如何将值从一种形式传递到另一种形式? - How can I pass values from one form to another? 如何将图像从一种形式传递到另一种形式 - How to pass an image from one form to another one 家庭作业如何将值从一种形式传递到另一种形式的列表中的对象 - Homework how to pass values from one form to an object in a list in another form 如何将列表从表单发送到另一个表单 - How to send a list from a form to another one 我可以在C#中将对象列表从一个表单传递到另一个表单吗? - Can I pass a List of objects from one Form to another in C#? 如何在C#中将多个记录从一种形式传递到另一种形式? - How can I pass multiple records from one form to another form in C#? 如何将值从一个窗体传递到另一个窗体的私有TextBox? - How to pass a value from one Form to a private TextBox in another Form? 如何在C#中同时将datagridview的多个单元格值从一种形式传递到另一种形式? - How can I pass multiple cell values of datagridview from one form to another at same time in C#? 找不到如何将变量从一种形式传递给另一种C# - Can't find how to pass a variable from one form to another c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM