求.NET高手帮写一个简单程序

来源:百度知道 编辑:UC知道 时间:2024/06/22 03:53:44
就是一个小程序~点开一个窗口~上面是几个人的名字~然后有一个BUTTON~点一下那个button~就出来另一个窗口~上面是之前的随机的一个人的名字~~高分重谢~答案满意~保证再追加分数~~

private void button1_Click(object sender, System.EventArgs e)
{
Random r = new Random ();//随机数
int rndNum = r.Next(listBox1.Items.Count); //根据listbox1的内内容设置随机数的范围
MessageBox.Show(this.listBox1.Items[rndNum].ToString());//显示listBox1的内容
}

form1的代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;

using System.Data.OleDb;
using System.Reflection;

namespace WindowsApplication1
{

public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void button2_Click(object s