Load event:
pictureBox3.Image
= Image.FromFile(@"C:\Users\salman\Documents\Visual Studio
2013\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Resources\roll.png");
= Image.FromFile(@"C:\Users\salman\Documents\Visual Studio
2013\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Resources\roll.png");
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
roll dice button:
label2.Text = logics.rolldice(pictureBox3).ToString();
class:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
class logics
{
public static int rolldice(PictureBox px)
{
int dice = 0;
Random r = new Random();
dice = r.Next(1, 7);
px.Image = Image.FromFile(@"C:\Users\salman\Documents\Visual Studio
2013\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Resources\" + dice + ".png");
2013\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Resources\" + dice + ".png");
px.SizeMode = PictureBoxSizeMode.StretchImage;
return dice;
} //roll dice
method end................
method end................
}
}
Please send full program
ReplyDeletesource code
ReplyDeletecode
ReplyDelete