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 SturkenboomPosted Nov 23, 2014, 11:14 PM
{
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 ChoudharyPosted Nov 23, 2014, 11:18 PM
Use following method after
string row = String.Format ("{0} {1}", current.name, current description);
listBox.AddRow (row ) ;
after that it will work fine.