无法在文本框中输入点 [英] Cannot enter dot in a textbox

查看:48
本文介绍了无法在文本框中输入点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网格视图中,我有链接类型列.由于我们无法编辑这种类型的单元格,如果用户选择单元格进行编辑,我将显示一个文本框.但我的文本框无法读取点字符.我检查了按键按下"和文本更改"事件,但不会为点作为输入触发事件.
我可以输入除点以外的任何字符或符号.. ;(

In my grid view i have link type column. as we cannot edit cell of such type i am displaying a text box if user select cell for editing. but my text box is unable read dot character. I checked "key pressed" and "text changed" events but events are not triggered for dot as a input.
I can enter any character or symbol except dot.. ;(

我在 gridview 的单元格点击事件上显示文本框

I am displaying textbox on cell click event of gridview

if (DataGrid.Columns[e.ColumnIndex].GetType().Name == "DataGridViewLinkColumn")
{
txt_Data.Location    =   DataGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location;

txt_Data.Size        =   DataGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Size;

txt_Data.Visible     =   true;
txt_Data.Focus();
}

并为单元格赋值

private void txt_Data_TextChanged(object sender, EventArgs e)
{
  DataGrid.CurrentCell.Value = txt_Data.Text;
}

推荐答案

几天前我遇到了这个问题,这让我发疯了.. 终于弄明白了,所以我回到这里来启发:) 问题是用于编辑的 EditingControlWantsInputKey 方法control.. 确保它对所有字符(或至少是您想要支持的字符)返回 true .. 完成!:D

I had this problem a few days ago and it was driving me nuts.. Finally figured it out so I've come back here to enlighten :) The problem is the EditingControlWantsInputKey method for your editing control.. Make sure it returns true for all characters (or at least the characters you want to support).. Done! :D

这篇关于无法在文本框中输入点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆