You have not shown enough code, but I'm going to assume this function is inside a TextChanged
event.
If that is the case, you're checking if TextBox5
has some text, then you're clearing a number of controls on the form. You haven't shown other events and what they do, so it would be hard to tell you more at this point.
Consider debugging your code and stepping through it line by line, that way you can follow the logic of the program flow and see where the hiccup occurs...
I'd also change the first 3 lines:
if (textBox5.Text == "")
{ }
else
with if (!string.IsNullOrEmpty(this.textBox5.Text.Trim()))
, which means, if string is not empty (null or empty to be precise).
Hope this helps.
Good luck