Validation error does not block the gui - .net 2.0

  • Thread starter Thread starter Rolf Welskes
  • Start date Start date
R

Rolf Welskes

Hello,
I have the following:
a form, a datasource, in the form I have tabs, menus, listboxes, a
datagridView and textboxes.

All is bound to the datasource and works fine.

Now I have (beside other) with the textBox-events Valdiating and Validated
the validation of the textboxes which must be numbers.
If I enter a non number and change to another textbox, the errorProvider
sets the icon beside the textbox with the error message.
All is fine.
Futher more in such a case the listbox, tabs, etc. all are block as long as
I have not corrected the error.

BUT:
I have a menu and the menu is not blocked, so the user could close the
application without knowing from the error.
Furthermore and that is very hard:
I can go to the datagridview, change the rows and work.
Since the textboxes are bound to the same datasource as the DataGridView,
the error is lost.

So how to block the user to use the menu and especially the datagridview
when an error in the textbox appears.

Thank you for any help.
Rolf Welskes
 
Hi Rolf,

In my opinion, if you doesn't want customer to edit data by dataGridView,
you can enable ReadOnly property of
dataGridView(this.dataGridView1.ReadOnly = true;). After that, everyone
should have to edit the data by text box. When closing the application from
menu, you may prompt a warning dialog to remind customer they are going to
close the application. You may also check all the values in textbox. If it
is invalid, prompt a warning message again...

Hope this helps,
Sincerely,
Wen Yuan
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello,
thank you for your help.
With the datagrid that is solved, I catch the MouseDownevent and
let it trough or not in error case.

But the problem is the menu.
It should not be possible to work with the menu when the error occurs.

What we have is the following problem:

I have a textbox with the events Validating and Validated.
If validating is raised and an error is given, I can do actions, for example
block the menu.

But the problem is:
When entering data in a textbox and click the menu,
the menu gets the focus, but the textbox does not loose the focuse,
means the event Validating is not raised.

this is a general problem (since 32-bit windows),
a control in a form does not loose focus when the focus goes anywhere not in
the same childwindow.

So what can I do, is there any other event which is raised,
my texboxes are in a usercontrol, so when going to the menu also the user
contol is left,
but is there an event?

Thank you for any help.
Rolf Welskes
 
Hi Rolf,
Thanks for your reply.

I reproduced the issue on my side. But, I'm afraid there is not an event
raised in textbox. However, (a trick), you may move the focus to a special
control when the mean item has been clicked. For example, there is a
dataGridView in form, you can set focus to this control. Because textbox
control losses the focus, the Validating event will be raised.

private void aaToolStripMenuItem_Click(object sender, EventArgs e)
{
dataGridView1.Focus();
.....
}

Hope this helps. Please let me know if you have any more concern on this.
We will follow up.
Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
 
Hello,
thank you.
I have solved it.
But it's not fine because you have events over many controls.
But it works, thank you again.
Rolf Welskes
 
Hi Rolf.
Thanks for your reply. You are welcome.

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
 
Back
Top