0

在我的主表单中,我创建了一个新表单:

private void buttonCreatePositionForm_Click(object sender, EventArgs e)
{ 
 f3 = new FormPosition(textBoxFiltermachineid.Text, textBoxFilterPositionFile.Text);
 f3.Show();
}

我还使用了一个使用主表单填充的字典:

Dictionary<String, List<Reorder>> reorderPerFilename = new Dictionary<string, List<Reorder>>();

class Reorder
        {
            public int reordernumber { get; set; }
            public string reordervalue { get; set; }
            public int reorder0 { get; set; }
            public int reorder1 { get; set; }
            public int reorder2 { get; set; }
            public int reorder3 { get; set; }
            public int reorder4 { get; set; }
            public int reorder5 { get; set; }
            public int reorder6 { get; set; }
        }

现在我想将此字典及其内容传递给新表单,以便可以使用这些值:

        public FormPosition(string machineId, string reorderCondition)
        {
            InitializeComponent();

            if (!string.IsNullOrWhiteSpace(machineId) && !string.IsNullOrWhiteSpace(reorderCondition))
            {
                labelMachineId.Text = machineId;
                labelReorderCondition.Text = reorderCondition;     
            }  
        }

我不断收到错误

错误 4 参数 1:无法从 'System.Collections.Generic.Dictionary>' 转换为 'System.Collections.Generic.Dictionary>'

尝试这个时:

private void buttonCreatePositionForm_Click(object sender, EventArgs e)
        {
            f3 = new FormPosition(reorderPerFilename, textBoxFiltermachineid.Text, textBoxFilterPositionFile.Text);
            f3.Show();
        }

class Reorder2
        {
            public int reordernumber { get; set; }
            public string reordervalue { get; set; }
            public int reorder0 { get; set; }
            public int reorder1 { get; set; }
            public int reorder2 { get; set; }
            public int reorder3 { get; set; }
            public int reorder4 { get; set; }
            public int reorder5 { get; set; }
            public int reorder6 { get; set; }
        }

        public FormPosition(Dictionary<String, List<Reorder2>> reorderPerFilename, string machineId, string reorderCondition)
        {
            InitializeComponent();

            if (!string.IsNullOrWhiteSpace(machineId) && !string.IsNullOrWhiteSpace(reorderCondition))
            {
                labelMachineId.Text = machineId;
                labelReorderCondition.Text = reorderCondition;     
            }  
        }

我在这里做错了什么?

4

1 回答 1

0

您可以将属性添加到人员类。但它应该是静态属性。

无需创建实例即可访问静态属性。

它们在您的应用程序启动时创建,并且它们一直存在到您的应用程序关闭

于 2015-12-22T11:56:39.927 回答