Exemple #1
0
        private void Button_Click(object sender, EventArgs e)
        {
            if (sender.Equals(this.btnSubmit))
            {
                Main   frm1          = (Main)this.Owner; //将本窗体的拥有者强制设为Main类的实例frm1
                Random rnd           = new Random();
                int    iRnd          = 0;
                int    index         = iSelectedCnt;
                string sSelectedText = this.lblSelected.Text;

                for (int intA = 0; intA < this.nudAmount.Value; intA++)
                {
                    while (index < 6)
                    {
                        iRnd = rnd.Next(1, 50);
                        if (!sSelectedText.Contains(iRnd.ToString()))
                        {
                            sSelectedText = sSelectedText + iRnd.ToString().PadLeft(2, '0') + " ";
                            index++;
                        }
                    }

                    frm1.AddPickNumber(sSelectedText.Trim());
                    index         = iSelectedCnt;
                    sSelectedText = this.lblSelected.Text;
                }

                this.Close();
            }
        }