Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未保存列表类型的设置_C#_Winforms - Fatal编程技术网

C# 未保存列表类型的设置

C# 未保存列表类型的设置,c#,winforms,C#,Winforms,我正在尝试制作一个winforms应用程序,通过输入描述、名称和图像,您可以获得项目的概述。我存储了这三个不同的字符串和图像列表,然后我试图保存它,但它不起作用 private void save_Click(object sender, EventArgs e) { Properties.Settings.Default.Name = new textList(); Properties.Settings.Default.Description = ne

我正在尝试制作一个winforms应用程序,通过输入描述、名称和图像,您可以获得项目的概述。我存储了这三个不同的字符串和图像列表,然后我试图保存它,但它不起作用

private void save_Click(object sender, EventArgs e)
    {
        Properties.Settings.Default.Name = new textList();
        Properties.Settings.Default.Description = new textList();
        Properties.Settings.Default.Image = new imageList();

        foreach (var item in names)
        {
            Properties.Settings.Default.Name.Add(item.Text);
        }
        foreach (var item in description)
        {
            Properties.Settings.Default.Description.Add(item.Text);
        }
        foreach (var item in pictureBox)
        {
            Properties.Settings.Default.Image.Add(item.BackgroundImage);
        }
        Properties.Settings.Default.Save();
    }

private void Oversigt_Load(object sender, EventArgs e)
    {
        Properties.Settings.Default.Reload();

        Properties.Settings.Default.Name = new textList();
        Properties.Settings.Default.Description = new textList();
        Properties.Settings.Default.Image = new imageList();
        foreach (var item in Properties.Settings.Default.Image)
        {
            var pic = new PictureBox();
            pic.Size = new Size(192, 108);
            pic.BackgroundImageLayout = ImageLayout.Zoom;
            pic.BackgroundImage = item;
            pic.Location = new Point(47, 209);
            Controls.Add(pic);
            pictureBox.Add(pic);
        }

        foreach(var item in Properties.Settings.Default.Name)
        {
            var name = new Label();
            name.AutoSize = true;
            name.Text = item;
            name.Font = new Font("Microsoft Sans Serif", 17);
            name.ForeColor = Color.White;
            Controls.Add(name);
            names.Add(name);
        }
        foreach(var item in Properties.Settings.Default.Description)
        {
            var desc = new Label();
            desc.AutoSize = false;
            desc.Size = new Size(192, 63);
            desc.Text = item;
            desc.Font = new Font("Microsoft Sans Serif", 10);
            desc.ForeColor = Color.White;
            Controls.Add(desc);
            description.Add(desc);
        }
        arrangeProject();
    }

class textList : List<string>
{
}

class imageList : List<Image>
{
}

因此,我不确定从这里走到哪里

有关将通用列表保存到应用程序设置的正确方法,请参见第一个副本。请注意,要做到正确有点挑剔。请参阅其他副本,了解不太优雅但更简单的解决方法。我已经阅读了以下内容:。我一直想知道怎么做,所以我想我应该问问自己。
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]