2

The column names are shown in the listview but the lines not. So i think this part is correct:

List<string[]> list = gl.ReadCSV(fileNameBox.Text);

GridView gridView = new GridView();
listViewTable.View = gridView;
foreach (string st in list.First())
{
     gridView.Columns.Add(new GridViewColumn
    {
        Header = st,
        DisplayMemberBinding = new Binding(st)
    });
}

But i think something is missing here. Or not correct.

for (int i = 1; i < list.Count; i++)
{
    listViewTable.Items.Add(new FHInfo(list[i][0], list[i][1], list[i][2], list[i][3], list[i][4], 
                    list[i][5], list[i][6], list[i][7], list[i][8], list[i][9], list[i][10], list[i][11], list[i][12]));
}
listViewTable.Items.Refresh();

Summary: the listview stays empty, only the column names are shown. I mean, the listViewTable.Items.Add(...) adds everything (i can see that when i debug) bu nothing is shown in the GUI. (only the column names) Thanks for help.

This is the FHInfo class:

class FHInfo
{
    private string building;
    private string floor;
    private string room;
    private string roomdesc;
    private string distributor;
    private string patchpanel;
    private string socket;
    private string switchFH;
    private string lineCard;
    private string port;
    private string vlan;
    private string device;
    private string gigabitAble;

    internal string Building { get => building; set => building = value; }
    internal string Floor { get => floor; set => floor = value; }
    internal string Room { get => room; set => room = value; }
    internal string Roomdesc { get => roomdesc; set => roomdesc = value; }
    internal string Distributor { get => distributor; set => distributor = value; }
    internal string Patchpanel { get => patchpanel; set => patchpanel = value; }
    internal string Socket { get => socket; set => socket = value; }
    internal string SwitchFH { get => switchFH; set => switchFH = value; }
    internal string LineCard { get => lineCard; set => lineCard = value; }
    internal string Port { get => port; set => port = value; }
    internal string Vlan { get => vlan; set => vlan = value; }
    internal string Device { get => device; set => device = value; }
    internal string GigabitAble { get => gigabitAble; set => gigabitAble = value; }

    public FHInfo(string building, string floor, string room, string roomdesc, string distributor, string patchpanel, string socket, string switchFH, string lineCard, string port, string vlan, string device, string gigabitAble)
    {
        this.building = building;
        this.floor = floor;
        this.room = room;
        this.roomdesc = roomdesc;
        this.distributor = distributor;
        this.patchpanel = patchpanel;
        this.socket = socket;
        this.switchFH = switchFH;
        this.lineCard = lineCard;
        this.port = port;
        this.vlan = vlan;
        this.device = device;
        this.gigabitAble = gigabitAble;
    }
}
9
  • 1
    are you sure that list.Count > 1? Commented Jul 26, 2018 at 6:27
  • 1
    and issue is that lines are empty or listview is empty? Show us please FHFInfo class, this class should have properties, which names are exactly same as headers Commented Jul 26, 2018 at 6:29
  • I begin with 1 because in the first row (0) are the names of the columns. The lines are empty, when i debug, i can see, that the listview.Items.Add() adds everything but in the GUI the listview stays empty. (except the column names) Commented Jul 26, 2018 at 6:49
  • so could you please show as FHFInfo class? Commented Jul 26, 2018 at 6:51
  • did you tried to make your properites public? Commented Jul 26, 2018 at 7:02

1 Answer 1

2
  1. You need to have properites in class FHFInfo with names excatly the same as headers of your CSV file.
  2. These properites have to be public.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.