110,539
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
ArrayList al_Car = new ArrayList();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
return;
Car car = new Car(textBox1.Text,textBox2.Text,textBox3.Text);
al_Car.Add(car);
listView1.Items.Add("Car"+al_Car.Count.ToString());
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if(listView1.Items.Count>0)
{
if (listView1.SelectedIndices.Count > 0)
{
textBox1.Text = ((Car)al_Car[listView1.SelectedIndices[0]]).s_1;
textBox2.Text = ((Car)al_Car[listView1.SelectedIndices[0]]).s_2;
textBox3.Text = ((Car)al_Car[listView1.SelectedIndices[0]]).s_3;
}
}
}
}
public class Car
{
public string s_1, s_2, s_3;
public Car(string s1,string s2, string s3)
{
s_1 = s1;
s_2 = s2;
s_3 = s3;
}
}
}
//先获取3个textbox的值
string a = this.textbox1.text;
。。。
//然后存入listbox
listBox.Items.Add();
至于你说的checklistbox多出一个选项。勾选哪个选项,点击一个按钮能调出这个car实例的3组信息...
就加一个checkbox呗 然后设置它们的可见性Visibility呗 具体的你表达不清楚我也没看太懂
给你个大概做法让你有目的的查吧...都是从新手过度来的 学吧~