using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Program1
{
public partial class Form1 : Form
{
private int n;
private int min, max;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
checkedListBox1.Items.Clear();
try
{
n = Convert.ToInt32(textBox1.Text);
min = Convert.ToInt32(textBox2.Text);
max = Convert.ToInt32(textBox3.Text);
if (n <= 0)
{
MessageBox.Show("请输入大于 0 的个数值 !");
}
if (max <= min)
{
MessageBox.Show("请输入大于 最小值的最大值 !");
}
}
catch {
MessageBox.Show("参数的 输入 有误 !");
}
Random r = new Random();
List l = new List();
for (int i = 0; i < n; i++)
{
l.Add(r.Next(min, max));
listBox1.Items.Add(l[i]);
}
l.Sort();
for (int i = 0; i < n; i++)
{
checkedListBox1.Items.Add(l[i]);
}
}
private void button2_Click(object sender, EventArgs e)
{
CheckedListBox.CheckedItemCollection ci = checkedListBox1.CheckedItems;
if (ci.Count != 0)
{
StringBuilder s = new StringBuilder();
s.Append("你选择的数值 为 :");
foreach (int i in ci)
{
s.Append(i + "、 ");
}
MessageBox.Show(s.ToString());
}
else {
MessageBox.Show("你没有选择任何数值 !");
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Program1
{
static class Program
{
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
阅读(174) | 评论(0) | 转发(0) |