如何将多个位图插入图像列表?

时间:2014-06-03 12:34:28

标签: c#

你好朋友我想将第二个表单转换为位图并将其加载到图像列表中 但当我运行显示空白图像的应用程序代替它时,这里是我的代码

     int nextImageNumber = 1;

    private void button1_Click(object sender, EventArgs e)
    {

        panel3.Controls.Clear();
        var ofd = new OpenFileDialog();
        ofd.Filter = "DICOM Files (*.dcm;*.dic)|*.dcm;*.dic|All Files (*.*)|*.*";
        ofd.Multiselect = true;
        if (ofd.ShowDialog() == DialogResult.Cancel)
            return;
        OpenFile(ofd.FileName);
        var a = new DisplayForm(_file);
        a.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

        int abc = 1000;
        Thread.Sleep(abc);

        Bitmap bm = new Bitmap(a.Size.Width, a.Size.Height);
       a.DrawToBitmap (bm, new Rectangle(0, 0, a.Size.Width, a.Size.Height));
       string name = nextImageNumber.ToString();
       imageList1.Images.Add(name, bm);
       var listViewItem = listView2.Items.Add("Patient Name:" + label1.Text + "\n" + " ID:" + label2.Text + " , " + " Age:" + label3.Text);

       listViewItem.ImageKey = name;

       nextImageNumber++;

    }

0 个答案:

没有答案