2

I have an ArrayList

...    
while (reader.Read())
{
        decimal nr_zbor = reader.GetDecimal(cod_zbor);
        string airport = reader.GetString(name_aeroport);
        string company = reader.GetString(name_company);
        list.Add(nr_zbor);
        list.Add(airport);
        list.Add(company);
}
...

and I wish to put in the listview columns[zbor,airport,company], but I don't now how

fly = searchFly.GetFly(direction, country, theDate, DFlexible);

can you help me?

3 Answers 3

1

One option is to create a class with those 3 properties

class nac
{
   public decimal nr_zbor ...
   public string airport ...
   public string company ...
}

List<nac> nacs = new List<nac>();

Those properties are the columns

ListView Class

Sign up to request clarification or add additional context in comments.

Comments

1

ListViewItems may contain ListViewSubItems. The item itself will be shown in the first column, after that all subItems will be shown. So you may adapt your code to

while (reader.Read())
{
    decimal nr_zbor = reader.GetDecimal(cod_zbor);
    string airport = reader.GetString(name_aeroport);
    string company = reader.GetString(name_company);

    ListViewItem newItem = new ListViewItem(nr_zbor.ToString());
    newItem.SubItems.Add(airport);
    newItem.SubItems.Add(company);

    list.Items.Add(newItem); // assuming list is your listView
}

Make sure you set your ListView to View.Details so that columns will show up.

Comments

0

You can try this.

while(....)
{
   .........
   listview.Items.Add(new ListViewItem(nr_zbor), new ListViewItem(airport),new      
   ListViewItem(company);
}

I have not tested it.

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.