密钥启动文本框不起作用 [英] Key up event of a textbox is not working

查看:72
本文介绍了密钥启动文本框不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨dere,



i我在winapp工作。有2个文本框,1个下拉列表,1个日期时间选择器。我必须通过按下从1个控件移动到另一个控件输入。我的第一个控件是Paymode(下拉),第二个是PayDate(datetimepicker),第三个是PayAmount(文本框),第四个是Cred / CheqNo(文本框)。



因此,当我选择paymode中的现金时,它在第一时间完美地移动,当我在paymode中选择信用时,它会在第二次移动到下一个控制。有时它在日期控制附近,有时接近payamount。



它以前工作得很好,但现在还没有工作。已经检查了表格的关键预览属性..这将是我不明白的问题。请帮我解决这个..



i我发给你的代码,

hi dere,

i am working in winapp.Have taken 2 textbox with 1 dropdown n 1 datetime picker.I have to move from 1 control to another by pressing enter.My first control is Paymode(dropdown),2nd one is PayDate(datetimepicker),then 3rd one is PayAmount(Textbox) and fourth one is Cred/CheqNo(Textbox).

so while i choosing cash in paymode its moving perfectly in first time,bt when m choosing credit in paymode its nt moving to the next control in second time.sometimes its stuking near date control and sometimes near payamount.

it was working perfectly before,but not working now.have already checked the key preview property of the form..what would be the problem i dont understand.Please help me to solve this..

i am sending you the code,

private void txtPayAmnt_KeyUp(object sender, KeyEventArgs e)
       {
           if (e.KeyCode == Keys.Enter)
           {
               if (cmbPayMode.SelectedIndex == 0)
               {
                   MessageBox.Show("Please  Select  the  PayMode..", "Restaurant", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                   cmbPayMode.Focus();
                   if (cmbPayMode.Focus())
                   {
                       cmbPayMode.FlatStyle = FlatStyle.Popup;
                       cmbPayMode.BackColor = System.Drawing.Color.Brown;
                       cmbPayMode.ForeColor = System.Drawing.Color.White;
                   }
               }
               else if (cmbPayMode.SelectedIndex != 1)
               {
                  txtCredChq.Focus();
               }
               else
               {
                   int j = dgvPayDetails.CurrentRow.Index;
                   dgvPayDetails.Rows[j].Cells[0].Value = cmbPayMode.Text;
                   dgvPayDetails.Rows[j].Cells[1].Value = txtPayAmnt.Text;
                   dgvPayDetails.Rows[j].Cells[2].Value = txtCredChq.Text;
                   dgvPayDetails.Rows[j].Cells[3].Value = dtpPayDt.Text;
                   dgvPayDetails.Rows.Add();
                   dgvPayDetails.CurrentCell = dgvPayDetails.Rows[j + 1].Cells[0];
                   cmbPayMode.SelectedIndex = 0;
                   txtPayAmnt.Text = "";
                   txtCredChq.Text = "";
               }
           }
       }









谢谢..





Thanks..

推荐答案

这似乎是一个算法问题:



如果触发 cmbPayMode.SelectedIndex == 0 然后触发 cmbPayMode.SelectedIndex!= 1



唯一将触发 else 的情况是 cmbPayMode.SelectedIndex == 1
It's seems to be a problem of algorithm :

If cmbPayMode.SelectedIndex==0 is triggered then cmbPayMode.SelectedIndex != 1 is triggered too

The only case that the else will be triggered is if cmbPayMode.SelectedIndex == 1


这篇关于密钥启动文本框不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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