Validation of input elements and Form Closing

One of very often questions ask by WinForms developers is “How to make sure that if Form is Closing, no validation occurs in contained controls”?

For reference, validating input is rather straightforward:

1. Add ErrorProvider to Form
2. For control in question, add handlers for Validating and Validated events:

        private void tbFixPath_Validating(object sender, CancelEventArgs e)
            if (!ControlValidated(tbFixPath.Text))
                // Cancel the event and select the text to be corrected by the user.
                e.Cancel = true;
                tbFixPath.Select(0, tbFixPath.Text.Length);

                // Set the ErrorProvider error with the text to display. 
                   "Sorry, something went wrong during validation. Please check.");

        private void tbFixPath_Validated(object sender, EventArgs e)
                // After successful validation, clear error message.
                errorProvider1.SetError(tbFixPath, "");

3. Everything is fine, until user tries to close form where some input elements are not validated – closing will fail. In order to prevent this, if you are absolutely sure that you want to close such form, just add:

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
                e.Cancel = false;

so that no cancellation of closing event will occur.

I know that this is basic 🙂 but after I was ask for 10th time in 6 months, I figured that is better to note this somewhere 🙂

Firebird reaches 2.0 milestone

Firebird 2.0

Databases are very important in my area of work; as a simple storage (but rarely), as a smart relational actor in the game or even as replacement for application server, holding mass of business logic rules.

There are more and more very free and very powerful databases on database market. Some are completely free, and some are “entry” models for big guys. Whatever reasons are, they make developer life much, much easier.

One of my favorite free databases is Firebird – and it reached very important milestone: version 2.0. There is long list of enhancements, but to mention just some:

  • Table size is no longer limited to 30 Gb
  • Password encryption now uses a more secure password hash calculation algorithm (SHA-1), encryption becomes entirely server-based and password login is now required from any remote client
  • new interface for plugging in international character sets, including enhanced Unicode support, along with a number of new and corrected collations

Download link:

Let me mention other favorites:


MS SQL Server Express 2005 along with free management tool: SQL Server Management Studio Express – fast and sleek combination for rapid development under .Net 2.0 environment. There are of course limitations, but for most small and middle project this will work just fine.

Also, if you are using older version of SQL 2000 or lite version called MSDE please consider migrating to sQL 2005 – SQL 2000 family won’t be supported on Vista.


Oracle Database 10g Express Edition – lite version of “big” Oracle 10g. Perfect companion is Quests’s TOAD Free.

Welcome to yet another blog of mine

Welcome on my first English blog.

I am blogging more than two years on my Serbian blog and that is blog about general technical subjects which are interesting for wider audience. More details about myself you have here and in my resume.

Idea of this blog is to be highly technical and to deal with .Net, Asp.Net, Databases, Web sites, programming in general.

Hope that won’t be boring and that you will find interesting and useful stuff for you.

Once more, welcome on my english blog and thanks for reading 🙂