有问题让焦点正确 [英] Having problem to get the focus right

查看:62
本文介绍了有问题让焦点正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序不工作



有些文本框必须根据传入字段禁用和启用



以下代码有问题







if(string.IsNullOrEmpty(SqlCmd。参数[@ ERESPONSE2]。Value.ToString())||

string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE4]。Value.ToString())||

string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE3]。Value.ToString())||

!string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE1]。Value .ToString()));

{

txt_Resp_time2.Text = SqlCmd.Parameters [@ ERESPTIME2]。Value.ToString();

txt_Response2.Text = SqlCmd.Parameters [@ ERESPONSE2]。Value.ToString();

txt_Resp_time2.Enabled = true;

txt_Response2.Enabled = true;

txt_Response2.Focus();



txt_Resp_time4.Enabled = false;

txt_Response4.Enabled = false;

txt_Resp_tim e3.Enabled = false;

txt_Response3.Enabled = false;

txt_Resp_time1.Enabled = false;

txt_Response1.Enabled = false;

}





if(string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE1]。Value.ToString ())||

string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE4]。Value.ToString())||

string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE3]。Value.ToString())||

string.IsNullOrEmpty(SqlCmd.Parameters [@ ERESPONSE2 ] .Value.ToString()));

{

txt_Resp_time1.Text = SqlCmd.Parameters [@ ERESPTIME1]。Value.ToString();

txt_Response1.Text = SqlCmd .Parameters [@ ERESPONSE1]。Value.ToString();

txt_Resp_time1.Enabled = true;

txt_Response1.Enabled = true;

txt_Response1.Focus();



txt_Resp_time4.Enabled = false;

txt_Response4.Enabled = false;

txt_Resp_time3.Enabled = false;

txt_Response3.Enabled = false;

txt_Resp_time2.Enabled = false;

txt_Response2.Enabled = false; < br $>
}



我尝试过:



这是我试过但无法解决的代码

Program not working

There are text boxes which have to be disabled and enabled based on the incoming fields

Having problem with the following codes



if (string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE2"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE4"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE3"].Value.ToString()) ||
!string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE1"].Value.ToString())) ;
{
txt_Resp_time2.Text = SqlCmd.Parameters["@ERESPTIME2"].Value.ToString();
txt_Response2.Text = SqlCmd.Parameters["@ERESPONSE2"].Value.ToString();
txt_Resp_time2.Enabled= true;
txt_Response2.Enabled = true;
txt_Response2.Focus();

txt_Resp_time4.Enabled = false;
txt_Response4.Enabled = false;
txt_Resp_time3.Enabled = false;
txt_Response3.Enabled = false;
txt_Resp_time1.Enabled = false;
txt_Response1.Enabled = false;
}


if (string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE1"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE4"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE3"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE2"].Value.ToString())) ;
{
txt_Resp_time1.Text = SqlCmd.Parameters["@ERESPTIME1"].Value.ToString();
txt_Response1.Text = SqlCmd.Parameters["@ERESPONSE1"].Value.ToString();
txt_Resp_time1.Enabled= true;
txt_Response1.Enabled = true;
txt_Response1.Focus();

txt_Resp_time4.Enabled = false;
txt_Response4.Enabled = false;
txt_Resp_time3.Enabled = false;
txt_Response3.Enabled = false;
txt_Resp_time2.Enabled = false;
txt_Response2.Enabled = false;
}

What I have tried:

This are codes which I have tried and not been able to solve

推荐答案

请描述一些关于你的问题的更多细节:

这是您从程序中复制粘贴的实际代码吗?

您的ERESPONSE1-4参数有什么价值?

您看到了什么行为?

您期望的行为是什么?

只关注焦点还是启用/禁用控件?



无这个信息很难提出解决方案,因为我们不介意读者。



但是,如果这是你的程序,我发现了一个问题:

Please describe a few more details about your question:
Is this your actual code copy-pasted from your program?
What are the value of your ERESPONSE1-4 parameters?
What behavior do you see?
What behavior do you expect?
Is only the focus a problem or also the enabled/disabled controls?

Without this information it is difficult to propose a solution as we are not mind readers.

However, if this is your program, I see a problem:
if (string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE1"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE4"].Value.ToString()) || 
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE3"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE2"].Value.ToString())) ; 
{



if包含4行条件后跟分号;

这样就完成了你的if无论if条件的评估如何,都会执行空体和以下块。

这相当于:


The if contains 4 lines of conditions that are followed by a semicolon ";"
This completes your if with an empty body and the following block is executed regardless of the evaluation of the if conditions.
This is equivalent to this:

if (string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE1"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE4"].Value.ToString()) || 
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE3"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE2"].Value.ToString()))
{
}

{



因此,如果您的行为始终是启用了1个字段而其他所有字段都已禁用,请尝试删除;紧接在if和see之后,如果这解决了你的问题。


So if your behavior is always the 1 fields are enabled and all others are disabled, try removing the ";" immediately after the if and see, if this solves your problem.

if (string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE1"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE4"].Value.ToString()) || 
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE3"].Value.ToString()) ||
string.IsNullOrEmpty(SqlCmd.Parameters["@ERESPONSE2"].Value.ToString()))
{


这篇关于有问题让焦点正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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