i have an invoice form with a grid for items,loaded from a child form on key press.
keypress code in parent:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.F11))
{
childform obj = new childform ();
obj.ShowDialog();
DataTable dt = obj.Dt_sel_item;
}
}
In child form there is a search control which has an after find event on that event selected item is passed to parent and child form is closed and item is added on parent grid.
void fnd_item_AfterFind(object sender, EventArgs e)
{
if (this.fnd_item.ControlValue != string.Empty)
{
DataTable dt_item_filter = dt_find_fill.Copy();
dt_item_filter.DefaultView.RowFilter = "item_id=" + this.fnd_item.ControlValue;
dt_item_filter = dt_item_filter.DefaultView.ToTable();
dt_sel_item = dt_item_filter.Copy();
this.Close();
}
}
if i select item in search control of child form using mouse click,everything works fine.
i have added code to set focus on qty field of parent for the selected item using below code in the parents ProcessCmdKey event
try
{
keyglobalRow = grd_item.Rows.Count - 2;
}
catch { keyglobalRow = 0; }
grd_item.CurrentCell = grd_item.Rows[keyglobalRow].Cells[5];
grd_item.Rows[keyglobalRow].Cells[5].Selected = true;
If i use enter key on search control of child for selection focus of the parent grid after loading item proceeds to one column.
i think the parent form grids enter key event is trigg
ered .how can i restrict that only in this event handler,client need to move through columns in grid using tab and enter key.
plz share ur valuable suggestions