Link Labels C # - displaying a list of them

I am trying to add a list of related lables to a listview. I made it like this

        foreach (String s in values)
        {
            LinkLabel label = new LinkLabel();
            label.Text = s;
            txtBox.Controls.Add(label);
        }
    }

It adds only one item to the list, even if there are more. Any ideas?

ps), I can say that there are more elements from adding breakbpoint and using console.writeline in iteration

thank

+3
source share
2 answers

Controls ListViewor ListBoxnot intended to host child controls.

If you need it, then you should use a container control, for example Panel. I recommend using TableLayoutPanelor FlowLayoutPanel, which can automatically control the location of its child controls.

+2

. , listitem, .

, = > txtbox.Items.Count = 0; txtbox.Controls.Count = 2 for.

0

Source: https://habr.com/ru/post/1785883/


All Articles