C#——listbox的体验----显示数字

来源:互联网 发布:淘宝好评如何删除评价 编辑:程序博客网 时间:2024/05/17 06:35
/*烟台大学计算机学院学生      *All right reserved.      *文件名称:C#——listbox的体验----显示数字*作者:杨飞      *完成日期:2014年9月2日      *版本号:v1.0      *对任务及求解方法的描述部分:C#——listbox的体验----显示数字*我的程序:*/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;namespace WindowsFormsApplication1{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)        {        }        private void Form1_Load(object sender, EventArgs e)        {            Random d = new Random();            for (int i = 0; i < 10; i++)            {                int x = d.Next(10,100);                listBox1.Items.Add(x.ToString());            }        }        private void button1_Click(object sender, EventArgs e)        {            label2.Text= listBox1.SelectedItem.ToString() ;                 }    }}

运行结果:

心得体会:呵呵

0 0