English 中文(简体)
C# 滑坡how光只是随着时间的推移才显示出最后的形象,而所有幻灯片/图像箱则不会变得可见。
原标题:C# Slideshow only displays last image after time is up for all slides/picturebox not becoming visible

I am currently trying to create a program that will show a slideshow of pictures from an ImageList with variable show times from a ListView, which is acessed through a numericUpDown, but when I click the button to start, nothing happens, until the time of the slideshow ends, where the last slide is shown, then disappears straight away (if i leave out "pictureBox1.Visible = false" at the end, it stays).

现行法典:

private void buttonSlideshow_Click(object sender, EventArgs e)
{
    pictureBox1.Visible = true;

    for (int s = 0; s < listView1.Items.Count; s++)
    {
        listView1.Items[s].Selected = true;
        pictureBox1.Image = imageList1.Images[s];

        DateTime later = DateTime.Now.AddMilliseconds((double)numericUpDown1);
        while (DateTime.Now < later)
        {
        }

    }
        pictureBox1.Visible = false;
}

我已尝试过许多版本(包括使用时间手和围绕转换代码)的想法,什么是错的。

数字 假设1是滑坡的期间,它一直在使用惯性进行检测,但还是没有工作

最佳回答

这样做:

while (DateTime.Now < later)

Is blocking your UI thread. It can t redraw the screen while you are keeping it busy spinning it s wheels. Use a timer with a call back instead.

你需要稍微重新制定你的法典。 你们目前的幻灯不使用孔径,而是界定了一种变数,在你点击手中将其推为零,使你的照片箱可见,打上了第一个照片,然后开了你的时间。

In your timer handler, you ll increment the current index, check it against the length of you list of slides and, if you still have slides to display, load the next one and then start the timer again (or you can use a timer that fires repeatedly, although you might want to be careful that it doesn t fire again before you re done handling that last one). If there are no more slides left, just do you clean up and make your picture box invisible again.

一份最后说明是谨慎的,即将到来的是时间。 以赢利的形式,你可以使用该系统。 视窗。 表格:电离层和电离层的火灾时间有问题。 在挪威人民论坛中,你可以使用停机,也向法国宇宙航行局火焰。 另一些时间者通常在自己的read子里工作,而你不得不处理将任何本应更新的《国际调查》重新引入《国际调查》。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签