English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

for example i have the ff. in my listbox (receives input from textbox)

aaa
bbb
ccc
ddd

if i enter ccc again, the listbox will contain

aaa
bbb
ccc
ddd

instead of

aaa
bbb
ccc
ddd
ccc


can anyone give me the code? thank you

2007-03-10 16:17:25 · 1 answers · asked by Mikan 1 in Computers & Internet Programming & Design

1 answers

In the Click event for the button to add the item from the text box into the listbox:

bool found = false;
for(int i=0; i {
if(listbox.Items[i].Text == textbox.Text)
{
found = true;
break;
}
}
if(!found)
{
listbox.Items.Add( textbox.Text );
}

2007-03-10 17:54:47 · answer #1 · answered by Rex M 6 · 0 1

fedest.com, questions and answers