Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one form which have one tab control ..

My problem is that when i change tab page first time and press a tab key that time tab key is worked...but when i change tab page again that time tab key is not worked....

pls help me ...
Posted
Comments
Manoj Kumar Choubey 19-Dec-13 6:29am    
Please put some code what you doing, explain more ....
kavita painter 19-Dec-13 6:31am    
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Check if Enter is pressed
if (tabControl1.SelectedTab == ItemStock)
{
if (keyData == Keys.Enter || keyData==Keys.Tab)
{
// If there isn't any selected row, do nothing
if (GrdStock.CurrentRow == null)
{
return true;
}

// Display first cell's value
int col = GrdStock.CurrentCell.ColumnIndex;
int row = GrdStock.CurrentCell.RowIndex;

if (col < GrdStock.ColumnCount - 1)
{
col++;
}
else
{
col = 1;
row++;
}
if (row == GrdStock.RowCount)
row--;
// GrdStock.Rows.Add();

GrdStock.CurrentCell = GrdStock[col, row];
GrdStock.BeginEdit(true);
return true;
}
}

return base.ProcessCmdKey(ref msg, keyData);
}
kavita painter 19-Dec-13 6:31am    
when i press enter or tab it goes to the next cell
BillWoodruff 19-Dec-13 6:36am    
Your description is very incomplete. It seems like you have some other control named GrdSTock ... a DataGridView ? ... in one of the TabPages. What exactly is the behavior you want: do you want for GrdStock ... whatever that is ... not to respond to certain key presses ?

We're not psychics :)

1 solution

// Check if Enter is pressed
if (tabControl1.SelectedTab == ItemStock)
   { if (keyData == Keys.Enter || keyData==Keys.Tab)
       {


just switch this two if condition.i guess it will work


XML
<pre> // Check if Enter is pressed
if (keyData == Keys.Enter || keyData==Keys.Tab)
        {
             if (tabControl1.SelectedTab == ItemStock)
                { 
</pre>
 
Share this answer
 
Comments
kavita painter 20-Dec-13 7:17am    
no still it not worked;-(

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