Listview with first column exceeding limit

Asked

Viewed 230 times

0

Hello! I made a form using the library Materialskin

In this library there is a component called Listview (which would be similar to Winforms' Listview) that the first column gets bugged. Look at this image: inserir a descrição da imagem aqui

The correct would be to have the three dots as well as the CPF-CNPJ column, but the first column is superimposed on all the others when it has many characters. Does anyone know what might be the solution to this?

Edit 1 : Preferably a way other than simply giving a substring in the first column characters!!

Edit 2: I am filling the table with the following code:

fornecedores = new Fornecedor().retornaItens(tbFiltro.Text,30);
lstFornecedores.Items.Clear();

    foreach (Fornecedor fornecedor in fornecedores)
    {
        var item = new ListViewItem(new string[ {fornecedor.nome,fornecedor.cpfcnpj,fornecedor.tipoPessoa.ToString(),fornecedor.endereco});
            lstFornecedores.Items.Add(item);
    }
  • If you add the code instead of the image, it’s easier to help you.

  • put friend!

  • Already tried to edit column width? lstFornecedores.Column[index da coluna].Width = "tamanho desejado"; does not forget that he is a whole.

  • Yes, the width of each column is already defined, this problem only occurs in the first column. If you notice, the CPF/CNPJ column already does what I want automatically.

2 answers

0


I was able to solve it! Since the fault was only in the first column, I created a first column with width of 0 and filled it with an empty string. So it cuts automatically :)

inserir a descrição da imagem aqui

fornecedores = new Fornecedor().retornaItens(tbFiltro.Text, 30);
lstFornecedores.Items.Clear();

        foreach (Fornecedor fornecedor in fornecedores)
        {               
            var item = new ListViewItem(new string[]
            {"",fornecedor.nome,fornecedor.cpfcnpj,fornecedor.tipoPessoa.ToString(),fornecedor.endereco});
            lstFornecedores.Items.Add(item);
        }

0

Well come on, there are 3 types of Auto Sizing Column: ColumnHeaderAutoResizeStyle.None, ColumnHeaderAutoResizeStyle.HeaderSize and the ColumnHeaderAutoResizeStyle.ColumnContent .

to adjust the column[0] of the list just change the property SuaLista.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.None);

and if you want to increase the width of the column, just change the property SuaLista.Columns[1].Width = 150; or greater, by default the value is 60 width.

Below is an example: inserir a descrição da imagem aqui

  • I tried too and it didn’t work, I think it’s a bug from the material skin library.

Browser other questions tagged

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