Hello,
I am making a winform application that retrieves data from user with text box, and display on listBox.
Below is the ones I tried, but no error, and it's not working.
Help please! :)
private void Button_Click(object sender, EventArgs e)
{
current.name = nameTextBox.Text.Trim();
current. description = descriptionTextBox.Text.Trim();
listBox.BeginUpdate();
listBox.Items.Clear();
string row = String.Format ("{0} {1}", current.name, current description);
//listBox.Items.Add("{0} {1}", current.name, current description); //Another method I tried, but didn't work.
listBox.EndUpdate();
}

Wim SturkenboomRank #2,527 · 554 reputationPosted Nov 23, 2014, 6:14 PM EST
{
current.name = nameTextBox.Text.Trim();
current. description = descriptionTextBox.Text.Trim();
string row = String.Format ("{0} {1}", current.name, current description);
listBox.Items.Add(row);
}
You're making life far to complicated :-)
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Nov 23, 2014, 6:18 PM EST
Use following method after
string row = String.Format ("{0} {1}", current.name, current description);
listBox.AddRow (row ) ;
after that it will work fine.