In: Computer Science
I'm trying to space out my 3 inputs when they are displayed in the list box. I've tried putting "\t" and "" in between inputs and it makes the 3rd input not visible, I've tried expanding my listbox and it still wasn't visible either.
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],numTickets[index],costs[index].ToString("C"))); }
}
Below is the solution:
private void button2_Click(object sender, EventArgs e)
{
for (int index = 0; index < 5; index++)
{
listBox3.Items.Add("Ticket Name\t" + 123456 + "\t" +
23.67.ToString("C")); //try it that way
//listBox3.Items.Add(string.Format("{0, 10}{1, 10}{2, 10}", "Ticket
Name", 123456, 23.67.ToString("C"))); //this is also working
fine
}
}