如何从列表视图的每一行显示三个成员 [英] how to show three members in every row from listview

查看:95
本文介绍了如何从列表视图的每一行显示三个成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事社交网络工作

我只想在成员页面的列表视图的每一行中显示三个成员.

I''m working on social networking

I want to show three members only in every row from listview in members page

推荐答案

如果查看ListView方法,您将看到ListView.Add带有一个对象作为输入.现在,如果将单个元素(例如字符串)放入该ListView中,它将始终显示该值.插入对象会得到什么?

答:对象的名称空间.这表明您的对象正在调用它的ToString()方法.

因此,如果要在列表框中显示3个字段,则将所有3​​个字段都放入一个对象中,并重写ToString方法.

例如:

If you look at the ListView methods you will see that the ListView.Add takes an object as input. Now if you put a single element such as a string into that ListView, it will always display that value. What do you get if you insert an object?

Answer: the namespace of the object. And this demonstrates that your object is getting it''s ToString() method called.

So if you want to have 3 fields displayed in the ListBox, you put all three fields into a single object and override the ToString method.

For Example:

public class MyClass
{
    public string ClassName { get; set; }
    public int ClassLevel { get; set; }
    public string ClassGrade { get; set; }
    public override string ToString( )
    {
        return String.Format( "{0} {1}  ::  {2}", ClassName, ClassLevel.ToString( ), ClassGrade );
    }
}


尝试使用项目模板.
在项目模板中,使用具有三个td的表,然后在每个td中尝试放置一个成员的数据.
ListView链接 [
Try use item templates.
In the item template use a table having three td, then in each td try to place data for one member.
This ListView Link[^] link may help you.


这篇关于如何从列表视图的每一行显示三个成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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