winform中,当点击textbox弹出一个软键盘,请问要做么做,最好有代码。
展开全部
度娘查下键盘勾子,有很多Demo
public static string KeyBoard = "是";
public static void In_SystermInfo()
{
try
{
KeyBoard = "是";// dt.Select("kye = 'Keyboard'")[0]["kyevalue"].ToString();
} catch { KeyBoard = "是"; }
KeyBoard = "是";
}
#region 虚拟键盘是否启用
public static void IsKeyBoard(System.Windows.Forms.Form frm, string kb)
{
if (kb.Trim() == "是")
{
foreach (System.Windows.Forms.Control c in frm.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = true;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = true;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = true;
}
}
}
if (c.HasChildren)
{
HasControl(c, true);
}
}
}
if (kb.Trim() == "否")
{
foreach (System.Windows.Forms.Control c in frm.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = false;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = false;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = false;
}
}
}
if (c.HasChildren)
{
HasControl(c, false);
}
}
}
}
public static void HasControl(System.Windows.Forms.Control has, bool tof)
{
foreach (System.Windows.Forms.Control c in has.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = tof;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = tof;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = tof;
}
}
}
if (c.HasChildren)
{
HasControl(c, tof);
}
}
}
#endregion
public static string KeyBoard = "是";
public static void In_SystermInfo()
{
try
{
KeyBoard = "是";// dt.Select("kye = 'Keyboard'")[0]["kyevalue"].ToString();
} catch { KeyBoard = "是"; }
KeyBoard = "是";
}
#region 虚拟键盘是否启用
public static void IsKeyBoard(System.Windows.Forms.Form frm, string kb)
{
if (kb.Trim() == "是")
{
foreach (System.Windows.Forms.Control c in frm.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = true;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = true;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = true;
}
}
}
if (c.HasChildren)
{
HasControl(c, true);
}
}
}
if (kb.Trim() == "否")
{
foreach (System.Windows.Forms.Control c in frm.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = false;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = false;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = false;
}
}
}
if (c.HasChildren)
{
HasControl(c, false);
}
}
}
}
public static void HasControl(System.Windows.Forms.Control has, bool tof)
{
foreach (System.Windows.Forms.Control c in has.Controls)
{
if (c is HookExLib.DataGridViewX)
{
((HookExLib.DataGridViewX)c).Keyboard = tof;
}
if (c is HookExLib.TextBoxX)
{
((HookExLib.TextBoxX)c).Keyboard = tof;
}
if (c is System.Windows.Forms.ToolStrip)
{
foreach (System.Windows.Forms.ToolStripItem ti in ((System.Windows.Forms.ToolStrip)c).Items)
{
if (ti is HookExLib.toolStripTextBoxX)
{
((HookExLib.toolStripTextBoxX)ti).Keyboard = tof;
}
}
}
if (c.HasChildren)
{
HasControl(c, tof);
}
}
}
#endregion
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询