Click here to Skip to main content
15,906,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
C#
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..
Posted
Comments
What is the index of "credit" in Paymode(dropdown)?

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900