【问题标题】:Winforms listboxesWinforms 列表框
【发布时间】:2017-02-28 08:24:54
【问题描述】:

我有两种形式。在 2 形式中,我在 textbox 中添加 mp3 文件。关闭2窗体后,想在1窗体的列表框中显示文件信息。

2 形式:

    private void buttonChooseSong_Click(object sender, EventArgs e)
    {
        OpenFileDialog openfile = new OpenFileDialog();
        openfile.FileName = String.Empty;
        openfile.InitialDirectory = "C:\\";
        openfile.Filter = "MP3 File(*.mp3)|*.mp3";
        openfile.FilterIndex = 2;
        openfile.Multiselect = false;
        if (openfile.ShowDialog() == DialogResult.OK)
        {
            song.Name = openfile.SafeFileName;
            song.Path = openfile.FileName;
            textBoxSongName.Text = openfile.SafeFileName;
            buttonAddSong.Visible = true;
            Song nsong = new Song();
        }
    }
    private void buttonAddSong_Click(object sender, EventArgs e)
    {
        DialogResult = DialogResult.OK;
    }

如何在listbox中显示mp3文件信息的1种形式?

【问题讨论】:

  • 在您的 Form2 中定义一个公共属性来存储所选歌曲并从 Form1 访问它

标签: c# winforms listbox


【解决方案1】:

我以前也有同样的问题。只需转到 Form1 并右键单击并转到设计器,使您的 Form1 对象public

像这样:

public System.Windows.Forms.TextBox textBoxSongName;

按照这个来

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2012-10-12
    • 2011-01-04
    • 1970-01-01
    • 2023-03-22
    • 2011-02-06
    • 2016-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多