 <p>Put your nested loop into a function and return true/false whenever you want to break the loop?</p> <pre><code>bool Function() { for(int i = 0; i &lt; 10; ++i) { for(int j = 0; j &lt; 10; ++j) { if (error) { MessageBox.Show("THE ITEM ID DOES NOT EXIST.!"); return false; } } } return true; } </code></pre>