标题:亂數取圖片問題
取消只看楼主
temple_new
Rank: 2
等 级:论坛游民
帖 子:31
专家分:11
注 册:2009-4-1
结帖率:66.67%
 问题点数:0 回复次数:1 
亂數取圖片問題
表單上有一個 pictureBox 一個 Button
picturBox 有三張圖片用亂數方式選取
事件則寫在按鈕下: 即按一下按鈕時用亂數值抽選一張圖片並顯示

目前是不成功的, 想請各位高手幫助

語法:

public void Random()
        {
            System.Random ran1 = new Random();
            int i = ran1.Next(0, 3);
            switch (i)
            {
                case 0:
                    {
                        i = 0;
                        pictureBox1.Show();
                        pictureBox1.Load(@"Resources\1.gif");
                        break;
                    }
                case 1:
                    {
                        i = 1;
                        pictureBox1.Show();
                        pictureBox1.Load(@"Resources\2.gif");
                        break;
                    }
                case 2:
                    {
                        i = 2;
                        pictureBox1.Show();
                        pictureBox1.Load(@"Resources\3.gif");
                        break;
                    }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Show();
             Random();
        }
搜索更多相关主题的帖子: 成功 
2011-06-15 16:07
temple_new
Rank: 2
等 级:论坛游民
帖 子:31
专家分:11
注 册:2009-4-1
得分:0 
此問題已解決  謝謝
2011-06-19 19:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-342958-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.045028 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved