Listview不显示所有字母 [英] Listview does not show all letters

查看:75
本文介绍了Listview不显示所有字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题

如果您从下面的链接看图片,我有一个CustomerFrame类(在右侧)和一个ListView,它是MainForm类(在右侧)

当我在CustomerFrame上输入值时,它会出现在我的列表视图中,但仅在列表视图中显示为"[]".

有人知道为什么吗?!

http://imageshack.us/f/7/kasta4.png/ [

Hi i have a problem

If you look at the picture from the link below, i have a CustomerFrame class (on the right) and a ListView which is the MainForm class (on the right)

When i enter values on the CustomerFrame it appears in my Listview but only like this "[]" in the listview.

Does anyone know why and what can i do?!

http://imageshack.us/f/7/kasta4.png/[^]


and here are some code:

this is my add method from customerframe into mainform(listview)
 
private void MainForm_Load(object sender, EventArgs e)
 {
 CustomerFiles.Contact contact = new CustomerFiles.Contact();
 CustomerFiles.Address address = new CustomerFiles.Address();
 CustomerFrame customerframe = new CustomerFrame();
 

if (customerframe.ShowDialog() == DialogResult.OK) 
{
 listView1.Items.Add(contact.ToString(), address.ToString());
 }
 }
 
inside contact class
 
public override string ToString()
 {
 return string.Format("[{0}]", FullName);
 //PhoneData
 //EmailData
 //AddressData
 }
 
inside adress class
 
public override string ToString()
 {
 return string.Format("[{0}, {1}, {2}, {3}]", city, zipCode, country, street);
 }

推荐答案

您仅输入了国家(在屏幕截图中).
确保选择正确并将其正确放置在country 变量中-该代码不会显示.
You have only entered the country (in your screenshot).
Ensure that you are picking it and putting it in the country variable correctly - this code is not shown.


这里是一种可能的解决方案.首先为您的列表视图创建列.
Here is a possible solution. First create columns for your list view.
// Create some column headers for the data.
ColumnHeader columnheader = new ColumnHeader();
columnheader.Text = "Full Name";
this.listView1.Columns.Add(columnheader);
columnheader = new ColumnHeader();
columnheader.Text = "Address";
this.listView1.Columns.Add(columnheader);


然后创建要添加到列表视图中的列表项


Then create list items that are going to be added into the listview

if (customerframe.ShowDialog() == DialogResult.OK) {
    ListViewItem listviewitem = new ListViewItem(contact.ToString());
    listviewitem.SubItems.Add(address.ToString());
    this.listView1.Items.Add(listviewitem);
}


这篇关于Listview不显示所有字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆