473,657 Members | 2,537 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opinion wanted

Hi there,

Is there a general approach for preventing users from selecting a menu item
in an SDI or MDI application whenever the current field on your form is
invalid (assuuming the app consists of a data entry form). In my case, I'm
working with a "DataGridVi ew" which occupies the entire child window of an
MDI app but the problem likely applies to any control. If you've entered
invalid data into a "TextBox" field of a form for instance (in my case a
grid cell), it's likely that most if not all items in your menus as well as
most hotkeys should be off-limits until the user corrects the field. Without
taking great pain to prevent users from gaining access to these items
however (it's not always trivial), is there an easier approach. Thanks.
Mar 2 '07 #1
11 1356
The technique I use is to set, on the control(s), either Enabled or Visible
to false.

Another technique is to show a Dialog, which contains an input field, when
the error on the main form fails an audit. The Dialog is modal, meaning the
user must enter the data and dismiss the dialog before any other control can
be accessed. You process the Dialog by (re)auditing the data and reshowing
the Dialog if it is still incorrect. Else you accept it just as if it was
entered on the main form, and then continue with processing the form's other
input fields (in the same way).

"Jack White" <no_spam@_nospa m.comwrote in message
news:Oc******** ********@TK2MSF TNGP06.phx.gbl. ..
Hi there,

Is there a general approach for preventing users from selecting a menu
item in an SDI or MDI application whenever the current field on your form
is invalid (assuuming the app consists of a data entry form). In my case,
I'm working with a "DataGridVi ew" which occupies the entire child window
of an MDI app but the problem likely applies to any control. If you've
entered invalid data into a "TextBox" field of a form for instance (in my
case a grid cell), it's likely that most if not all items in your menus as
well as most hotkeys should be off-limits until the user corrects the
field. Without taking great pain to prevent users from gaining access to
these items however (it's not always trivial), is there an easier
approach. Thanks.

Mar 2 '07 #2
Thanks for the feedback.
The technique I use is to set, on the control(s), either Enabled or
Visible to false.
I find handling other controls easy enough because you can simply prevent
users from leaving the invalid control until it's valid. There are normally
custom events or overrides that assist with this, typically
"Control.OnVali dating()" and "Control.OnVali dated()". The problem is that
they don't prevent users from accessing the menu itself nor any hotkeys. For
that I'm finding a lot of re-wiring required to make everything work, even
if it's just disabling it (due to other issues I won't get into here). It's
not a smooth process.
Another technique is to show a Dialog, which contains an input field, when
the error on the main form fails an audit. The Dialog is modal, meaning
the user must enter the data and dismiss the dialog before any other
control can be accessed. You process the Dialog by (re)auditing the data
and reshowing the Dialog if it is still incorrect. Else you accept it
just as if it was entered on the main form, and then continue with
processing the form's other input fields (in the same way).
That's not a bad idea actually (for some controls anyway) but I'm wondering
if users would find it a little unwieldy. Maybe I can dock the field to the
dialog and then superimpose the whoe thing on the original field so the user
won't notice anything. A reusable control of this type would be useful for
this purpose but it's still unorthodox. You would also have to centralize
the logic for handling the field so it can now be called from the original
form and the dialog. I'll give it some more thought but I have to believe
there's a more mainstream way of handling this situation in general. Thanks
again though (appreciated).
Mar 3 '07 #3
On Mar 2, 6:23 pm, "Jack White" <no_spam@_nospa m.comwrote:
Hi there,

Is there a general approach for preventing users from selecting a menu item
in an SDI or MDI application whenever the current field on your form is
invalid (assuuming the app consists of a data entry form). In my case, I'm
working with a "DataGridVi ew" which occupies the entire child window of an
MDI app but the problem likely applies to any control. If you've entered
invalid data into a "TextBox" field of a form for instance (in my case a
grid cell), it's likely that most if not all items in your menus as well as
most hotkeys should be off-limits until the user corrects the field. Without
taking great pain to prevent users from gaining access to these items
however (it's not always trivial), is there an easier approach. Thanks.
Jack:

Are you asking how to validate the users data, or how to act once
validation has been processed?

Mar 3 '07 #4
Jack:
>
Are you asking how to validate the users data, or how to act once
validation has been processed?
I'm really asking if there's a mainstream way to prevent users from
selecting menu items or activating hot keys when they try to leave a control
that currently has invalid data in it. Relying on the "Control.Valida ting"
event for instance works fine for other controls (preventing the user from
selecting them) but it doesn't prevent users from selecting a menu item.
Most menu items however (and hot keys) are probably invalid at this stage as
well (just like other controls) but the user can click them anyway. The
plumbing involved to manually prevent it is often non-trivial and
inconsistent with the "Control.Valida ting" model. I'm wondering how others
handle this. Thanks for the feedback.
Mar 3 '07 #5
I use the Composite UI App block (CAB) which allows you to map menu
items, etc... to commands which I disable. When the command is
disabled, everything mapped to it is also disabled. The same thing
happens for hiding commands.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com

"Jack White" <no_spam@_nospa m.comwrote in message
news:#R******** ******@TK2MSFTN GP03.phx.gbl:
Jack:

Are you asking how to validate the users data, or how to act once
validation has been processed?

I'm really asking if there's a mainstream way to prevent users from
selecting menu items or activating hot keys when they try to leave a control
that currently has invalid data in it. Relying on the "Control.Valida ting"
event for instance works fine for other controls (preventing the user from
selecting them) but it doesn't prevent users from selecting a menu item.
Most menu items however (and hot keys) are probably invalid at this stage as
well (just like other controls) but the user can click them anyway. The
plumbing involved to manually prevent it is often non-trivial and
inconsistent with the "Control.Valida ting" model. I'm wondering how others
handle this. Thanks for the feedback.
Mar 3 '07 #6
>I use the Composite UI App block (CAB) which allows you to map menu items,
>etc... to commands which I disable. When the command is disabled,
everything mapped to it is also disabled. The same thing happens for
hiding commands.
I'll take a look at this. Thanks. Note however that disabling items is only
part of the story. When you write a "Control.Valida ting" handler for
instance, you'll typically display an error message for the user if the
current control is invalid and then cancel the event by setting
"CancelEventArg s.Cancel" to "true". This prevents users from changing focus
to another control. Since this doesn't prevent users from clicking a menu
item however (using the mouse or an accelerator key), you would have to
disable/enable these items at the very moment the control becomes
invalid/valid. Doing this isn't trivial however (it means validating a
textbox on every keystroke for instance) but even if you do disable them,
there's no feedback for the user as to why these items are suddenly
disabled. Instead, when they click a menu item (or use a hotkey), they
should see the same consistent error message that's normally displayed by
"Control.Valida ting". Unfortunately, wiring this all up is not a simple
task.
Mar 4 '07 #7
"Jack White" <no_spam@_nospa m.comwrote in message
news:OH******** *****@TK2MSFTNG P05.phx.gbl...
I'll take a look at this. Thanks. Note however that disabling items is
only part of the story. When you write a "Control.Valida ting" handler for
instance, you'll typically display an error message for the user if the
current control is invalid and then cancel the event by setting
"CancelEventArg s.Cancel" to "true". This prevents users from changing
focus to another control. Since this doesn't prevent users from clicking a
menu item however (using the mouse or an accelerator key), you would have
to disable/enable these items at the very moment the control becomes
invalid/valid. Doing this isn't trivial however (it means validating a
textbox on every keystroke for instance) but even if you do disable them,
there's no feedback for the user as to why these items are suddenly
disabled. Instead, when they click a menu item (or use a hotkey), they
should see the same consistent error message that's normally displayed by
"Control.Valida ting". Unfortunately, wiring this all up is not a simple
task.
IMO, you are going to a lot of trouble to make your app worse. Restricting
the user to a particular control when it is invalid is one of the worst and
most annoying UI designs possible. It gives your app a very unprofessional
feel and a large number of users will uninstall it as soon as they encounter
this feature (assuming they have a choice :-).

You should allow your users to leave the control and validate what they have
entered when they push ok or whatever is appropriate.

Michael
Mar 5 '07 #8
IMO, you are going to a lot of trouble to make your app worse. Restricting
the user to a particular control when it is invalid is one of the worst
and most annoying UI designs possible. It gives your app a very
unprofessional feel and a large number of users will uninstall it as soon
as they encounter this feature (assuming they have a choice :-).

You should allow your users to leave the control and validate what they
have entered when they push ok or whatever is appropriate.
No, I disagree with that and so does MSFT (based on how their
"Control.Valida ting()" model works). In my (long) experience, if a field
contains invalid data then it should be trapped immediately unless it's
either a cross-validation errror (i.e., the field itself contains valid data
but it's invalid in conjunction with some other field), or it's a mandatory
field that's currently blank but hasn't been filled in yet. These should be
validated when OK is clicked (or in a grid control like "DataGridVi ew", when
the user attempts to leave the row itself opposed to the cell). All other
validation errors should be trapped immediately since it makes no sense to
allow a user to leave a field (or a cell) if its data is invalid. This is
usually the ergonomically correct way of doing things and users wouldn't
(and shouldn't) expect otherwise. Moreover, in my own case, I have an MDI
child window which consists of one "DataGridVi ew" control that consumes the
entire window. Just about everything on my menus applies to that control so
if the current cell is invalid, then almost all menu items are off-limits.
Even if I did things the way you're suggesting, I would still need to treat
these menu items as if the OK button was pressed, validating my control and
preventing the user from exercising these items.
Mar 5 '07 #9
"Jack White" <no_spam@_nospa m.comwrote in message
news:eS******** ******@TK2MSFTN GP02.phx.gbl...
No, I disagree with that and so does MSFT (based on how their
"Control.Valida ting()" model works).
That's just plain wrong. MS rarely use the model you're describing in their
software. I was going to save never but I did think of at least 1 obscure
example. In the case when they do this (designing a query in MS Access), I
find it annoying and it is definately unnecessary (why can't I just leave
the field and fix it later?).
In my (long) experience, if a field contains invalid data then it should
be trapped immediately unless it's either a cross-validation errror (i.e.,
the field itself contains valid data but it's invalid in conjunction with
some other field), or it's a mandatory field that's currently blank but
hasn't been filled in yet. These should be validated when OK is clicked
(or in a grid control like "DataGridVi ew", when the user attempts to leave
the row itself opposed to the cell). All other validation errors should be
trapped immediately since it makes no sense to allow a user to leave a
field (or a cell) if its data is invalid.
What if they want to push cancel? What if they want to fill it in last? What
if they want to copy-paste the result from another field? What if they just
want to leave because they want to? There is absolutely no reason to force
them to remain at that field. It's annoying and treats the user as an idiot.

What you say about leaving the row does make some sense assuming leaving the
row acts as pushing ok. This is annoying also but as leaving a row is the
same as pushing ok you need to validate then and there.
This is usually the ergonomically correct way of doing things and users
wouldn't (and shouldn't) expect otherwise.
It's extremely rare these days (to have the focus restricted to the field)
and 99% of users would expect to be able to leave the field. Try watching
some users use such an app, they most definately do expect otherwise. You
can watch them try to leave the field, get suprised at the message, click
ok, try to leave again, get annoyed, eventually enter false data and then
push cancel.
Moreover, in my own case, I have an MDI child window which consists of one
"DataGridVi ew" control that consumes the entire window. Just about
everything on my menus applies to that control so if the current cell is
invalid, then almost all menu items are off-limits.
Other areas of the app should assume the previous data until valid data is
entered. Hence, nothing else should be off limits. This is fairly simple to
implement because as the data has not been saved to the database, the
database contains the previous data.
Even if I did things the way you're suggesting, I would still need to
treat these menu items as if the OK button was pressed, validating my
control and preventing the user from exercising these items.
No you wouldn't.

Michael
Mar 5 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2138
by: Ali Eghtebas | last post by:
Hi, I've made this regex to catch the start of a valid multiline comment such as "/*" in e.g. T-SQL code. "(?<=^(?:*'*')*?*)(?<!^(?:*'*')*?--.*)/\*.*?$" With Multiline option on. As we know the T-SQL single line comment starts with a "--" and the string character is a "'". Considering all this, from these lines below the pattern will only catch "/*
8
7224
by: Michael Winter | last post by:
In a recent post ("About C error" by Victor, 21 Sep 2003), comments were made about the poster's use of macros. What I would like to know is why they are considered bad? I'm not referring to their use as 'functions'; I realise the loss of type-safety and the possible evaluation errors that can occur. However, what would be the harm with numeric and text literals? Consider a number that plays a significant role in the implementation of...
35
2091
by: Sandeep Sharma | last post by:
Right from the time the first edition of K&R was released, the advantages of using symbolic constants, as opposed to "magic numbers", has been emphasized ---- and for good reason. I don't dispute that at all. However, it gets on my nerves when people carry this practice too far. Consider these examples (from the code written by a distinguished colleague): #define DASH '-' #define SLASH '/' #define SINGLE_BYTE 1
11
2548
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use opaque data types to transfer information in between them. At some stage I was stuck and needed to make a variable global, and I also needed to make the struct declaration public to some other parts. Looking through the code I found out that lots...
28
1978
by: SStory | last post by:
Hello Group. I am a VB/VB.NET programmer. I have done some C/C++ years ago. I am considering a job opportunity which is unfortunately in C# and not VB.NET. What is the group's opinion on the difficulty level/time frame of a VB.NET programmer learning to program in C#?
10
1690
by: Fao, Sean | last post by:
A guy I know never refactors his code and insists on putting everything in an event handler. For example, he does some initialization of a DataGrid in the ItemDataBound event handler (which is actually the wrong place for his initialization, anyhow, because it has *nothing* to do with the items being bound, but that's another topic, altogether). At any rate, some times, it's necessary to "refresh" the control to take advantage of an...
15
1882
by: =?Utf-8?B?TWljaGVsIFBvc3NldGggW01DUF0=?= | last post by:
In my opinion rethrowing exceptions without providing anny extra information is a totall waste Examples : in my opinion wrong : A: Public sub DoSomeStuff() Try do it
5
1034
by: azrael | last post by:
id like to hear your opinion about something. I just started using Prolog yesterday and i have my doubts about it, but it seems to me something like object oriented. so i wanted to ask you how usefull prolog is. Sure this is no prolog newsgroup so my question is: because it seems object oriented, how important is it by understanding python and improving my python skills. because i just started it, i may bee totaly wrong or i...
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.