DataGridView, how to disable cell validation on closing form?

B

Backwater Geezer

DataSource is an ArrayList.
Some of the columns have Format = N2.

The problem is that if I enter invalid data into an N2 formatted column
I cannot close the form by clicking on the form's Close (X) button,
FormClosing fires after cell validation.

I don't want to do my own cell formatting nor validation nor add my
Close button.

Is there any clever way of solving this problem without using Win API?

Thanks

MH
 
D

Doug Holland

I've not fully tested this potential solution, but the Form class has a
Closing event and assuming this event fires first before the validation of
your DataGridView you could then disable the DataGridView validation.
Alternatively, you could subclass your Form with an abstract FormBase class
which contained a FormClosing boolean property which could be set by the
forementioned Closing event. Then the validation event handlers could check
this boolean value before validating the data.

Hope that all makes sense...

- Doug
 
B

Backwater Geezer

Doug said:
I've not fully tested this potential solution, but the Form class has
a Closing event and assuming this event fires first before the
validation...

Thanks Doug but you could save youself time by reading all what I wrote.

MH
 
D

Doug Holland

I read alot of posts and guess I missed that little nugget of information ...
just trying to help though.
 
M

miher

Hi,
I'm not sure i understand Your question well.
If You have a filename in Your application and You wish to open it in the
default program Windows uses to open it in, use the Process.Start(string
fileName) method.
For example this:
Process.Start(@"c:\myfile.txt") ;
will open myfile.txt in notepad (assuming Your system maps notepad for the
extension of txt).

Please let me know if i misunderstood Your question.

Hope You find this useful.
-Zsolt


in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top