Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working on social networking

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

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:

C#
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 );
    }
}
 
Share this answer
 
Comments
NDebata 18-Aug-11 22:07pm    
List box is different from 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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900