Let's say I have a listbox and two buttons in a windows form application. When I click button1, "button1" is added to the listbox. When I click button2 "button2" is added as a new entry.
What I'm trying to do is have button2 added next to the previous entry instead of as a new entry. Something like "button1 + button2". Can this be done?
You just need to update an existing item on the form, not add a new one. Check this out:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("A");
listBox1.Items[0] = listBox1.Items[0] + "B";
}
}