How to Remove items from listbox using button c# [Resolved]

Posted by Amulya under C# on 4/27/2013 | Points: 10 | Views : 2009 | Status : [Member] | Replies : 1
Suppose in form load items will be added to listbox and their is a button.when i click button records will be removed from listbox.




Responses

Posted by: Satyapriyanayak on: 4/27/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
private void Form3_Load(object sender, EventArgs e)
{
listBox1.Items.Add("a");
listBox1.Items.Add("b");
listBox1.Items.Add("c");
}

private void button1_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 0)
{
listBox1.Items.RemoveAt(listBox1.Items.Count - 1);
}
}

If this post helps you mark it as answer
Thanks

Amulya, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response