简体   繁体   中英

Listview items are added as columns instead of rows in C# how do I fix?

I am having problems with a subborn listview object. I have set it up exactly the same way as one that is functioning properly. The problem is when I add items in with a for each statements they are added as rows instead of columns. Hopefully this is simple.

My constructor code

String userstring;

        this.Users.Columns.Add("User");

        foreach (User user in UserListing.userListing)
        {
            userstring = "";
            userstring += user.getUsername() + " "; 
            userstring += " Has Admin Rights:" + user.getRights().ToString() + " "; 
            userstring += " Has Write Access:" + user.getRights().ToString();
            this.Users.Items.Add(new ListViewItem(userstring));
        }
        this.Show();

I had the same problem, and I fixed it by changing from

myListView.View = View.LargeIcon;

to

myListView.View = View.Details;

Should fix your problem as well.

Well, I just want to add that I was using the Properties in the Visual Studio and changed View to List. That was solution to my problem.

Click here to See the Picture

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM