If the user has clicked on the button 10 times then it should appear a messagebox
It’s not clear why you’re trying to use a loop for this. There’s nothing over which to iterate in the description. You’re simply incrementing a counter with each click and performing an action when the counter equals a given value.
First you need to track the number of clicks. A class-level property should do the trick:
private int NumberOfClicks { get; set; }
Then in your click handler, you increment it:
NumberOfClicks++;
Each time it’s incremented, check if it’s at 10 yet and show the message:
if (NumberOfClicks == 10)
MessageBox.Show("some message");
(You could additionally reset the counter in the if
block, so that the message is shown every 10 clicks. Or check if NumberOfClicks % 10 == 0
for the same effect. Etc.)