dimanche 1 mars 2015

On Screen Keypad in application C#

I am trying to Create KEYPAD for my application for a touch screen computer, I can't use windows onscreen keyboard. in my application in Form I have my KEYPAD GROUPBOX and I have multiple textbox's and one datagridview.


I did try to use SendKeys.Send() by this code


enter image description here


for code :



public partial class Form1 : Form
{
const int W_ACTIVATE = 0x08000000;

public Form1()
{
InitializeComponent();
}

protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= W_ACTIVATE;
return param;
}
}

private void button1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
string btnTag = btn.Tag.ToString();
switch (btnTag)
{
case "0":
SendKeys.Send("(0)");

break;
case "1":
SendKeys.Send("(1)");
break;
case "2":
SendKeys.Send("(2)");
break;
case "3":
SendKeys.Send("(3)");
break;
case "4":
SendKeys.Send("(4)");
break;
case "5":
SendKeys.Send("(5)");
break;
case "6":
SendKeys.Send("(6)");
break;
case "7":
SendKeys.Send("(7)");
break;
case "8":
SendKeys.Send("(8)");
break;
case "9":
SendKeys.Send("(9)");
break;

default:
// Do Something
break;
}
}
}


But it doesn't work,I need Help ,I would like to know how to make the keys type into the textbox and active cell in Datagridview which is focused.


Aucun commentaire:

Enregistrer un commentaire