Dear Friends, please check my code , i want to uptade data with pressing A+ctrl ... but it dose nto work?cord is bellow...

        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if(e.KeyCode==Keys.A && e.Control)
            {
                try
                {
                    scb = new SqlCommandBuilder(da);
                    da.Update(dt);
                    MessageBox.Show("Recode updated", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Form2 f1 = new Form2();
                    f1.Show();               //this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

You should not use OnKeyDown. It raises the KeyDown event, use that instead.

thx dear ddande ,
Please, suggest me what can i use intead of OnKeyDown ?

Well KeyDown. Click on the word KeyDown in my previous post.

Can u give me any example ?ddanbe

Perhaps try to watch this video.

Dear Danbe,
Please, check this is working in my other form.

  protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.A && e.Control)
            {
                if (txt_ProName.Text == "")
                {
                    MessageBox.Show("Please, Enter Required information mentioned by (*)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    int row = 0;
                    dgv_Selected.Rows.Add();
                    row = dgv_Selected.Rows.Count - 2;
                    dgv_Selected["col_Batch", row].Value = txt_Batch.Text;
                    dgv_Selected["col_ID", row].Value = txt_ProID.Text;
                    dgv_Selected["col_ItemName", row].Value = txt_ProName.Text;
                    dgv_Selected["col_Mfg", row].Value = dp_MfgDate.Text;// Mfg date
                    dgv_Selected["col_Exp", row].Value = dp_ExpDate.Text;//Exp Date
                    dgv_Selected["col_Qty", row].Value = txt_TQty.Text;
                    dgv_Selected["col_Pprice", row].Value = txt_PPrice.Text;
                    dgv_Selected["col_MRP", row].Value = txt_MRP.Text;
                    dgv_Selected["col_Value", row].Value = txt_Value.Text;
                    dgv_Selected["col_Rack", row].Value = txt_Rack.Text;

                    txt_Batch.Clear();
                    txt_ProID.Clear();
                    txt_ProName.Clear();
                    txt_ItemQty.Text = "0";
                    txt_QtyLmt.Text = "0";
                    txt_TStkQty.Text = "0";
                    txt_StkPos.Text = "0";
                    txt_SubQty.Text = "0";
                    txt_Rack.Text = "0";
                    txt_PPrice.Text = "0.00";
                    txt_MRP.Text = "0.00";

                    txt_TQty.Text = "0";
                    txt_Value.Text = "0.00";

                    //table.Rows.Add(textBox6.Text, textBox7.Text, textBox5.Text);

                    //dataGridView1.DataSource = table;
                }

            }
        }

Public Const WM_KEYDOWN As Integer = &H100
Event Down_Key(key As List(Of Integer))
Private Sub Key_Down(key As List(Of Integer)) Handles Me.Down_Key

    For x = 0 To keys.Count - 1
        Select Case keys(x)
            Case 68

            Case 37

            Case 39

              'CASE key & key

        End Select
    Next
    keys = New List(Of Integer)
End Sub

Dim keys As List(Of Integer) = New List(Of Integer)
Protected Overrides Sub WndProc(ByRef m As Message)

    If m.Msg = GameWorks.WM_KEYDOWN Then

        'keyarray(index) = m.WParam

        Debug.Print(m.WParam)
        keys.Add(m.WParam)
        RaiseEvent Down_Key(keys)
    End If
    If m.Msg = GameWorks.Func.WM_KEYUP Then
        If m.WParam = 37 Then

        ElseIf 39 Then

        End If
    End If

    MyBase.WndProc(m)
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.