JustinNiu 2015-11-23 07:49 采纳率: 0%
浏览 2239

C#中做一个抽奖功能,然后抽奖名单通过已有的文档拖拽到C#程序中

只做好了抽奖代码

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;



namespace 抽奖综合Bata1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            开始抽奖ToolStripMenuItem.Enabled = false;
        }
        string[] namelist;
        int nameIndex = 0;
        private void 选取姓名列表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog myFile = new OpenFileDialog();
            if (myFile.ShowDialog() == DialogResult.OK)
            {
                string FileName = myFile.FileName;
                namelist = File.ReadAllLines(FileName, Encoding.GetEncoding(0));
                nameIndex = 0;
                MessageBox.Show("你选中了:" + namelist.Length.ToString() + "个候选人");
                开始抽奖ToolStripMenuItem.Enabled = true;
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {
            label1.Text = "一等奖:" + namelist[nameIndex];
            nameIndex = (nameIndex + 1) % namelist.Length;
        }

        private System.Windows.Forms.Timer myTimer;
        private void 开始抽奖ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            myTimer = new System.Windows.Forms.Timer();
            myTimer.Interval = 50;
            myTimer.Tick += new EventHandler(label1_Click);
            myTimer.Start();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (myTimer != null)
                myTimer.Stop();
        }

将文本拖拽到C#程序中然后就可以就开始抽奖怎么来实现?

  • 写回答

1条回答 默认 最新

  • C_XiaoMing 2015-11-23 10:14
    关注
    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名