分隔ListBox中的输出



我很难将列表框中显示的每个项目隔开,因为它们靠得太近了。我已经尝试了下面的代码&也尝试过"而不是";\t〃;但当我做任何一个时,我的第三个价值就会消失。

private void button2_Click(object sender, EventArgs e)
{
//clear any previous values
listBox3.Items.Clear();
for (int index = 0; index < currentCapacity; index++)
{
listBox3.Items.Add(string.Format("{0, -10}{1, 10}{2, 10}", 
name[index],"t", numTickets[index],"t", costs[index]));
}
}

这样您就可以用空格/tap连接您的项目,而不是将它们添加为项目

private void button2_Click(object sender, EventArgs e) 
{
//clear any previous values
listBox3.Items.Clear();
for (int index = 0; index < currentCapacity; index++)
{
listBox3.Items.Add(string.Format("{0, -10}{1, 10}{2, 10}", 
name[index] + "t", numTickets[index] + "t", costs[index]));
}
}

最新更新