I want to use data validation approach, when I do not allow to change focus
until proper data is entered into field (Microsoft refers it "Validating
Control Data by Restricting Focus").
Problem is that I need several events to fire ignoring validation rules. In
case of common form controls (eg. button, other field, etc) I set
CausesValidation false and get the result.
But how do I do that for form? In my special case I want to allow close form
without meeting my valition rules in field control.
Form.CausesValidation = false property does not seem to give me desired
results.
Thanks in advance, any ideas would be welcome...
Ramunas Urbonas
You may set the form and all control's CausesValidation property to false,
if you want to close the window without validation. If system finds one of
the controls
CausesValidation properties is true, it will validate the data. This is a
sample demonstrating how to close a window without Validation:
private void button1_Click(object sender, System.EventArgs e)
{
foreach(Control ctl in this.Controls)
ctl.CausesValidation = false;
this.CausesValidation = false;
this.Close();
}
I hope this is helpful.
Best regards,
Lion Shi, MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: "Ramas" <ra...@fortas.ktu.lt>
Subject: validating and causesvalidation
Date: Mon, 13 May 2002 11:40:12 +0200
Lines: 19
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <#5RN1Im#BHA.1692@tkmsftngp05>
Newsgroups: microsoft.public.dotnet.framework.windowsforms
NNTP-Posting-Host: 213.226.135.154
Path: cpmsftngxa08!tkmsftngp01!tkmsftngp05
Xref: cpmsftngxa08 microsoft.public.dotnet.framework.windowsforms:19493
X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms