Cannot enter dot in a textbox

北慕城南 提交于 2019-12-13 06:49:33

问题


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.
EDIT: I can enter any character or symbol except dot.. ;(

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();
}

And assigning a value to cell as

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

回答1:


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



来源:https://stackoverflow.com/questions/2544054/cannot-enter-dot-in-a-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!