在单击其他单选按钮之前先提示? [英] Prompt first before clicking a different radio button?

查看:67
本文介绍了在单击其他单选按钮之前先提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:



  if ( !cboModel1.Text.Equals( string  .Empty)||!cboVBrand1.Text.Equals( string 。空)||!txtVType1.Text.Equals( string  .Empty)||!cboChassis1.Text.Equals( string .Empty)||!lblPlate1.Text.Equals(  ### ###)||!txtVColor1.Text.Equals( string  .Empty)||!cboSType1.Text.Equals( string .Empty)||!txtSPrice1.Text.Equals( string  .Empty))
{
DialogResult change = MessageBox.Show( 丢弃条目并选择旧车? PROCEED?, MessageBoxButtons.YesNo);

if (change == DialogResult.Yes)
{
clearDisable_Old();
rdoOld.Checked = true ;
rdoNew.Checked = false ;
}

else
{
rdoOld.Checked = ;
rdoNew.Checked = true ;
}
}





我有两个收音机按钮: 旧车新车

最初用户必须先输入一个单选按钮才能进入字段中的一些数据。

我想要发生的是当用户点击一个单选按钮并在至少一个字段中输入一些信息时,他突然点击另一个单选按钮(假设他改变了主意),首先会有提示,所以他输入的所有数据都不会立即清除。什么事件适合这个?

解决方案

如果这是Windows Forms我将使用验证 [ ^ ]事件,因为您需要能够取消基于操作的操作在用户输入上。



CancelEventArgs [ ^ ]有一个属性取消,可以将其设置为true以防止单选按钮更改其状态。

无。这实际上是我听过的最糟糕的设计理念之一。但是,什么是关于一个事件?首先,显而易见的是,你只是因为点击尚未发生而无法进行任何处理。



在实践中,有总是点击之前的一些事件。例如,在使用鼠标单击某些内容之前,您将调用鼠标输入事件和少量鼠标移动事件。但是使用可以在没有鼠标的情况下点击:点击事件纯粹是功能性的,这是以不同方式执行的动作:鼠标,键盘,甚至是程序设计(我不推荐)。你可以处理聚焦事件(你提到类似的东西),但是可以点击一个控件而不需要关注它。



更重要的是,所有这些事件原则上不能使用,因为它们都不会导致实际点击:用户可以只使用鼠标和控制焦点来玩。这种可能性是基本的用户权利,你永远不应该把它拿出来。比如说,关于焦点或选择的所有变化,你可以在状态行或类似的东西上显示不同的信息,但从来没有任何模态;移动鼠标也一样。打破这个简单的规则会让用户疯狂,人们永远不会同意使用你的软件。



如果你想要一些设计建议,你必须制定你的最终目标。它应该是最终的,也就是说,你不应该在你的问题的表述中放置任何事件和类似的技术细节。



-SA

I have this snippet of code:

if (!cboModel1.Text.Equals(string.Empty) || !cboVBrand1.Text.Equals(string.Empty) || !txtVType1.Text.Equals(string.Empty) || !cboChassis1.Text.Equals(string.Empty) || !lblPlate1.Text.Equals("### ###") || !txtVColor1.Text.Equals(string.Empty) || !cboSType1.Text.Equals(string.Empty) || !txtSPrice1.Text.Equals(string.Empty))
            {
                DialogResult change = MessageBox.Show("Discard entries and select an old vehicle?", "PROCEED?", MessageBoxButtons.YesNo);

                if (change == DialogResult.Yes)
                {
                    clearDisable_Old();
                    rdoOld.Checked = true;
                    rdoNew.Checked = false;
                }

                else
                {
                    rdoOld.Checked = false;
                    rdoNew.Checked = true;
                }
           }



I have two Radio Buttons: Old Vehicle and New Vehicle.
Initially the user has to select one of the radio buttons first before entering some data in the fields.
What I want to happen is when the user has clicked a radio button and entered some info in at least one field, when he suddenly clicks on the other radio button (suppose he changed his mind), there will be a prompt first so all the data he has entered won't be immediately cleared. What would be the event fit for this?

解决方案

If this is Windows Forms I would use Validating[^] event since you need the ability to cancel the operation based on the user input.

The CancelEventArgs[^] has a property Cancel which can be set to true to prevent the radio button from changing it's state.


None. That is actually one of the worst design ideas I ever heard of. But, what's about an event? First of all, it's apparent that you cannot do any handling just "before clicking", just because the "clicking" had not yet happened.

In practice, there are always some events preceding a click. For example, before you click something with the mouse you invoke the "mouse enter" event and few "mouse move" events. But the use can "click" without a mouse: the "click" event is purely functional, this is an action performed in different ways: mouse, keyboard, even programmatical one (which I would not recommend). You can handle "got focus" event (you mentioned something similar), but it's possible to "click" a control without focusing it.

More importantly, all those events cannot be used in principle, because they all may not lead to an actual click: the user can just play around with the mouse and the control focus. This possibility is the fundamental user right, you should never take it out. Say, on all changes on focus or, say, selections, you can show different information on status line, or something similar, but never anything modal; same goes about moving the mouse. Breaking this simple rule will drive the users crazy, people will never agree to use your software.

If you want some design advice, you have to formulate your ultimate goal. It should really be ultimate, that is, you should not put any events and similar technical detail in the formulation of your problem.

—SA


这篇关于在单击其他单选按钮之前先提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆