一个登录 的winfrom窗体,当单击文本框时弹出一个窗体,弹出的窗体中是虚拟键盘,当我点击弹出虚拟键盘后登录窗体就没有焦点了,我给文本框的单击事件中加上了 this.Focus();还是不起作用。我现在需要的效果是点击文本框弹出 虚拟键盘 输入的汉字或者其他字母可以显示到文本框中,请问应该如何做呢?

解决方案 »

  1.   

    弹出的模拟键盘窗体不管有多少按键,你只需要给他开发一个单击事件 如 ClickEvent而Form1中,对该窗体对象实例的该事件进行监听如 KeyForm a = new KeyForm();
    a.ClickEvent +=  Msg;
    a.Show();        public void Msg(string str)
            {
                textbox1.Text = str;
            }
    参考窗体传值:
    http://topic.csdn.net/u/20110831/16/bbd83b30-1e5f-4d21-bde0-1604f88d8b32.html
      

  2.   


    例如:窗体A 中有个文本框   窗体B 中是虚拟键盘
    点击 A 中文本框 弹出的B,当使用虚拟键盘时 A中的文本框没有焦点,键盘按下的字母等 不能显示到A中的文本框
      

  3.   

    还没解决那?昨天就看到你着问题了.这是一个别人的例子,你应该可以参照一下.using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace ZTEncrypt
    {
        public partial class MainForm : Form
        {
            public MainForm()
            {
                InitializeComponent();
            }        private MyDialog m_dlg;        //此窗口弹出的窗体在子窗体通过按钮关闭后传回子窗体文本框的值
            private void toolStripButton1_Click(object sender, EventArgs e)
            {
                MyDialog dlg = new MyDialog(richTextBox1.Text);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    richTextBox1.Text = dlg.TextBoxValue;
                }
            }
            //此窗口弹出的窗体可以将子窗体中文本框的值立即传回
            private void toolStripButton2_Click(object sender, EventArgs e)
            {            if (m_dlg == null)
                {
                    m_dlg = new MyDialog(richTextBox1.Text);                m_dlg.TextBoxChanged += new EventHandler(
                        (sender1, e1) =>
                        { richTextBox1.Text = m_dlg.TextBoxValue; }
                    );
                    //    m_dlg.TextBoxChanged += new EventHandler(
                    //    (sender1, e1) =>
                    //    { richTextBox1.Text = m_dlg.TextBoxValue; }
                    //);
                    //相当于
                    //m_dlg.TextBoxChanged += new EventHandler(m_dlg_textboxchanged);                //...                //private void m_dlg_textboxchanged(object sender1, EventArgs e1)
                    //{
                    //    richTextBox1.Text = m_dlg.TextBoxValue;
                    //}                m_dlg.FormClosed += new FormClosedEventHandler(
                        (sender2, e2) => { m_dlg = null; }
                    );
                    m_dlg.Show(this);
                }
                else
                {
                    m_dlg.Activate();
                }
            }    }
    }上面是父窗体using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace ZTEncrypt
    {
        public partial class MyDialog : Form
        {
            public MyDialog(string Param)
            {
                InitializeComponent();
                TextBoxValue = Param;
            }        public event EventHandler TextBoxChanged;        public string TextBoxValue
            {
                get { return textBox1.Text; }
                set { textBox1.Text = value; }
            }        public MyDialog() : this("") { }
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if (TextBoxChanged != null)
                    TextBoxChanged(this, e);
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.DialogResult = DialogResult.OK;
                Close();
            }
        }}
    这是子窗体你把父窗体中toolStripButton2_Click事件中调用的时间改一下大概就可以了.
      

  4.   

     if (Application.OpenForms["登陆窗体名称"] == null)
                {
                }
                else
                {
                    Application.OpenForms["登陆窗体名称"].Focus();
                }
      

  5.   

    在文本框点击事件里实例化软键盘窗体:
    A a = new A();
    a.showDialog(this);
    再winform窗体中设置文本框的可见性为 public
    在虚拟键盘单击事件里写:
    WinForm win = new WinForm();
    文本框的值=你选的值
      

  6.   


    键盘的哪个是csdn 上下载的用户控件
      

  7.   

    这个 虚拟键盘的 下载地址是:http://download.csdn.net/download/huyelei/2460881
      

  8.   

    可以用一下12楼的方法,要在用户名和密码框里都实现一个
    A a = new A();
    a.showDialog(this);
      

  9.   

    namespace FrmCJ_抽奖_
    {
        public partial class Form1 : Form
        {
            Thread t;
            public Form1()
            {
                InitializeComponent();
                Control.CheckForIllegalCrossThreadCalls = false;
            }        private void button1_Click(object sender, EventArgs e)
            {
                ThreadStart ts = new ThreadStart(PhoneNumber);
                t = new Thread(ts);
                t.Start();
                Console.Read();
            }
            public void PhoneNumber()
            {
                string[] str = new string[6];
                str[0] = "110(条子号码)";
                str[1] = "15250421031(XXX)";
                str[2] = "15952413534(XXX)";
                str[3] = "15601201878(XXX)";
                str[4] = "18614222511(XXX)";
                str[5] = "15954181915(XXX)";            for (int i = 0; i < str.Length; i++)
                {
                    Thread.Sleep(100);
                    this.textBox1.Text = str[i];
                    if (i==str.Length-1)
                    {
                        i = 0;
                    }
                }
            }        private void button2_Click(object sender, EventArgs e)
            {
                t.Abort();
                this.button2.Enabled = true;
            }