[英]show listview item in a textbox
there is a listview which stores names from my a textbox and when i select a single name from a row in my listview i want that name to be shown back in my textbox. 有一个列表视图,用于存储我的文本框中的名称,当我从列表视图中的一行中选择一个名称时,我希望该名称显示在我的文本框中。 how can i make it ?
我该怎么做? there is a people LIst i have stored all the person details
我已经存储了所有人的详细信息
List<person> people = new List<person>();
private void Form1_Load(object sender, EventArgs e)
{
String path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
if(!Directory.Exists(path+"\\AddressBook Data\\"))
Directory.CreateDirectory(path+"\\AddressBook Data\\");
if(!File.Exists(path+"\\AddressBook Data\\PeopleData.xml"))
File.Create(path +"\\AddressBook Data\\PeopleData.xml");
}
private void button2_Click(object sender, EventArgs e)
{
person p = new person();
p.name = textBox1.Text;
p.email = textBox2.Text;
p.streetAddress = textBox3.Text;
p.birthday = dateTimePicker1.Value;
p.addtionalNote = textBox4.Text;
people.Add(p);
listView1.Items.Add(p.name);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
dateTimePicker1.Value = DateTime.Now;
}
you need to set the View
of ListView to the List
. 您需要将ListView的
View
设置为List
。
Add follwoing statements in form_Load: 在form_Load中添加以下语句:
listView1.View = View.List;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.