所以我在使用C#表单时遇到了一些麻烦。我创建了一个客户名单,其中存储了名称,郊区和银行账户余额。使用下一个和上一个按钮我需要能够让用户浏览列表中的当前5个对象。我的计划是这样做的,当用户点击按钮时,文本框将填充相关信息。客户和其他细节是按钮的原因是后来我需要能够更新存储在这些字段中的信息,所以我认为这样做的好方法是擦除文本框中已有的内容,输入新的信息,然后按按钮进行更新。使用下一个和上一个按钮浏览列表
不管怎么说,我的主要问题是,我需要用我的视图按钮在我的列表中移动
这是我的形式看起来像:
我目前的形式代码是这样的:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Customer c1 = new Customer("Sibel Yilmaz", "Wollongong", 2500, 3000, 5000);
Customer c2 = new Customer("John Doe", "Figtree", 2547, 2500, 3655);
Customer c3 = new Customer("Mariah Moore", "Coniston", 2500, 7000, 36000);
Customer c4 = new Customer("Jessica Blackshaw", "Bellambi", 3500, 6000, 4750);
Customer c5 = new Customer("Suzan Yilmaz", "Wollongong", 2500, 2000, 47110);
List<Customer> customers = new List<Customer>();
customers.Add(c1);
customers.Add(c2);
customers.Add(c3);
customers.Add(c4);
customers.Add(c5);
}
private void Form1_Load(object sender, EventArgs e) { }
private void button2_Click(object sender, EventArgs e) { }
private void button6_Click(object sender, EventArgs e) { }
private void textBox4_TextChanged(object sender, EventArgs e) { }
private void Customer_Click(object sender, EventArgs e) { }
}
而且我Customer
类:
public class Customer
{
protected string name;
protected string suburb;
protected int postcode;
protected double credit_balance;
protected double saving_balance;
public Customer(string name, string suburb, int postcode, double credit_balance,
double saving_balance)
{
this.name = name;
this.suburb = suburb;
this.postcode = postcode;
this.credit_balance = credit_balance;
this.saving_balance = saving_balance;
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Suburb
{
get { return suburb; }
set { suburb = value; }
}
public int Postcode
{
get { return postcode; }
set { postcode = value; }
}
public double Credit_Balance
{
get { return credit_balance; }
set { credit_balance = value; }
}
public double Savinig_Balance
{
get { return saving_balance; }
set { saving_balance = value; }
}
}
请帮助我,让我知道什么是最好的方式去做这件事。
数据绑定是一种方式。 – terrybozzio 2014-09-20 15:50:30