Advertisement
jlalt

Function

May 23rd, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1.         private bool ItemIsIn(ListBox ListID, string Item)
  2.         {
  3.             foreach(String ItemGot in ListID.Items)
  4.             {
  5.                 if(ItemGot.Equals(Item))
  6.                 {
  7.                     return true;
  8.                 }
  9.             }
  10.             return false;
  11.         }
  12.  
  13. Example:
  14.  
  15.             if (ItemIsIn(listBox1, "Ali"))
  16.             {
  17.                 MessageBox.Show("Ali Hsat");
  18.             }
  19.             else
  20.             {
  21.                 MessageBox.Show("Ali Nist :|");
  22.             }
  23.             if (ItemIsIn(listBox1, "Reza"))
  24.             {
  25.                 MessageBox.Show("Reza hast");
  26.             }
  27.             else
  28.             {
  29.                 MessageBox.Show("Reza nist :|");
  30.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement