G
Guest
Hi All,
I am trying to determine if the user clicked the "x" close button within the
controlbox of the form (top right corner - next to minimize and maximize
buttons).
I am using the datagridview within VB2005. I validate the values in the row
when the user leaves the row via the grid's RowValidating event. I want to
allow the user to exit the application by clicking the "x".
The problem: The RowValidating event is triggered before the form's closing
event. If the user has entered invalid data, I do not allow the user to
leave the row until the the data has been corrected. However, if the user
clicks the "x", I don't want the user to have to fix the bad value before
exiting the application, I just want the application to close. I need a way
to determine if the user clicked the "x" - from within the RowValidating
event. I've taken the long route and figured out the cursor's position and
the approximate size of the the "x" box and it's position - in order to
figure out if the cursor is within the "x" area, however I'm thinking there's
got to be a more efficient way of determining whether the user clicked the
"x". I have other buttons on the form that I check the .Focused property of
(ex. if I'm in the midst of the RowValidating event, I can determine if the
user clicked the Add button by checking whether cmdAdd.Focused = True) to
determine whether the user clicked them.
Thanks in advance for any assistance that is offered! Have a great day!
I am trying to determine if the user clicked the "x" close button within the
controlbox of the form (top right corner - next to minimize and maximize
buttons).
I am using the datagridview within VB2005. I validate the values in the row
when the user leaves the row via the grid's RowValidating event. I want to
allow the user to exit the application by clicking the "x".
The problem: The RowValidating event is triggered before the form's closing
event. If the user has entered invalid data, I do not allow the user to
leave the row until the the data has been corrected. However, if the user
clicks the "x", I don't want the user to have to fix the bad value before
exiting the application, I just want the application to close. I need a way
to determine if the user clicked the "x" - from within the RowValidating
event. I've taken the long route and figured out the cursor's position and
the approximate size of the the "x" box and it's position - in order to
figure out if the cursor is within the "x" area, however I'm thinking there's
got to be a more efficient way of determining whether the user clicked the
"x". I have other buttons on the form that I check the .Focused property of
(ex. if I'm in the midst of the RowValidating event, I can determine if the
user clicked the Add button by checking whether cmdAdd.Focused = True) to
determine whether the user clicked them.
Thanks in advance for any assistance that is offered! Have a great day!