Invisible speakers in Listview

Asked

Viewed 487 times

0

I have a listview with a series of columns, but I’d like to hide a few, how do I do that?

  • 1

    WPF? Win Forms? Web Forms?

  • Ana, you’ve solved your problem ?

  • Hello @Rovannlinhalis yes I did! Thank you all for your help :)

2 answers

1


It seems to me ListView works in a similar way to TabControl, where it is not possible to define a property Visible.

However when you add a column to the ListView, it is also an object within your Form, which can be accessed by the name defined to it.

In the example, I used a listView and added 3 columns, then I remove and add the name column columnHeader2:

//Removendo
if (listView1.Columns.Contains(columnHeader2))
    listView1.Columns.Remove(columnHeader2);

//Adicionando
if (!listView1.Columns.Contains(columnHeader2))
{
    listView1.Columns.Add(columnHeader2);
    //Defino a posição dela novamente, caso contrário ela estará na última coluna.
    columnHeader2.DisplayIndex = 1;
}

0

I think only by defining the column as Width equal to 0, which will hide it.

seuListView.Columns[indiceDaColuna].Width = 0;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.