4
Reply

How to add a exact number of items to listbox from textbox.

raju patil

raju patil

Oct 14 2014 12:52 AM
898
if (textBox1.Text != "" || textBox1.Text != "")
{
if (!listBox1.Items.Contains(textBox1.Text))
{
   listBox1.Items.Add(textBox1.Text);
   textBox1.Text = "";
}
 
I can add items to listbox by above code,
but i am not getting how to add exact number of items to listbox through textbox, For eg: i want to add only 7 items in listbox, if i try to add 8th item it should not take it. i know its normal question but i m new in C# could someone please help me.

Answers (4)