0

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);
                }
            }
        }
3
Contributors
8
Replies
45
Views
3 Weeks
Discussion Span
Last Post by Michael_9
0

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

0

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;
                }

            }
        }
0

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

Edited by Michael_9: add key down constant

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.