>Thank you very much for the solution. Come to think of it that is how I used to do the same thing in VFP.<You're welcome. See, VFP isn't all that different from .NET now, is it? < vbg >
~~Bonnie
>
>>Einar,
>>
>>
>>Is there any way to prevent the form from closing?<>>
>>Yes, put your code in the Closing event handler instead, and use the CancelArgs to cancel the close when necessary.
>>
>>~~Bonnie
>>
>>
>>
>>>I've got a simple input form with an OK, a Cancel button and a combobox.
>>>The OK button has DialogResult = OK.
>>>I thought I would add some code to the click event of the OK button just in case the user "forgot" to select something from the combobox. If nothing is selected I want to display a messagebox (or slap the user upside the head) and return back to the form. The problem I have noticed is that when DialogResult is set for the button the form closes by itself after the code has executed.
>>>Is there any way to prevent the form from closing?
>>>
>>>Thanks,
>>>Einar