【问题标题】:Virtual keyboard input to data grid view [duplicate]数据网格视图的虚拟键盘输入[重复]
【发布时间】:2016-06-22 06:34:42
【问题描述】:

我想从虚拟键盘输入数字。

我通过 sendKeys 尝试过。它没有按预期工作。它替换数字

dataGridViewTransation.Focus();
SendKeys.Send("{4}");

如何克服这个问题?

【问题讨论】:

  • 当我在“RichTextBox”上使用您的代码 sn-p 时,它工作正常。你能发布更多代码吗?当您按下 gui 上的一个数字按钮时,这两行是否都会发生?
  • 是的,当我按数字键时在两行
  • 我关闭了帖子作为链接帖子的副本。如果您对链接的答案有任何疑问,请告诉我。
  • @RezaAghaei 我会尝试它的

标签: c# .net forms winforms


【解决方案1】:

我认为您不能将文本附加到 DataGridView 单元格。我会将当前值存储在一个字符串中,然后在将文本设置为单元格之前更新该变量。

        private void button1_Click(object sender, EventArgs e)
    {
        //Get the currently selected Cell
        string msg = String.Format("Row: {0}, Column: {1}",
        DGV.CurrentCell.RowIndex,
        DGV.CurrentCell.ColumnIndex);

        //Update our New Cell Value Data
        newValue = newValue + "4";

        //Apply the New Cell Value Data to the Selected Cell
        this.DGV.CurrentCell.Value = newValue;
    }

【讨论】:

    猜你喜欢
    • 2014-02-09
    • 2012-11-18
    • 2012-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 2011-12-07
    • 1970-01-01
    相关资源
    最近更新 更多