Hiding or Closing a Windows Form on C#

822 views Asked by At

I have a windows form which have a textbox & a button on it. I'll show & use this form for filtering some datagrid columns when right clicked their column header. And this form will be using constantly obviously. Now I'm thinking, Should I close it everytime or simply hide & reshow when needed? Which is the best for performance & memory? Or do you suggest any other thing for this filtering type?

2

There are 2 answers

0
CodeCaster On BEST ANSWER

Which is the best for performance & memory?

"Best" isn't a question nor a SMART requirement.

Of course if you just hide the form, it and its contents will stay in memory. This means your application uses more memory, but on the other hand, when you need to show the form again, you won't have to load the entries from the database again - making it appear faster.

If it's a form you really frequently need, I'd just hide and re-show it. See Hide form instead of closing when close button clicked how to do this.

0
i486 On

If the app runs very fast, it may be better to close it. If loading is heavy - hide it.