验证datagridview中的特定单元格 [英] validation of a specific cell in datagridview
本文介绍了验证datagridview中的特定单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有一个datagridview包含可编辑的文本框
现在我想在按键事件上验证选定的单元格,以便一个单元格在c#.net 3.5中仅接受整数值
我必须对按键事件进行验证,因为单元格仅接受整数值
解决方案
也许这会有所帮助:
http://www. eggheadcafe.com/community/csharp/2/10161001/validation-to-insert-only-valid-string-in-datagridview-cell.aspx [ function OnlyInteger(txt) { var selectedCell = txt.值; 如果(isNaN(selectedCell)) alert(selectedCell + " ); 如果(selectedCell == <" ) alert(selectedCell + " ); }
//在您的editabel文本框上,将以上函数称为
< 输入 类型 =" id =" runat =" önclick =" / >
//希望您可以找到一些出路
在这里,您可以查看示例的完整详细信息:
演练:在Windows窗体DataGridView控件中验证数据 [ 解决方案
Maybe this helps:
http://www.eggheadcafe.com/community/csharp/2/10161001/validation-to-insert-only-valid-string-in-datagridview-cell.aspx[^]
//U can do via javascript as
function OnlyInteger(txt) { var selectedCell=txt.value; if(isNaN(selectedCell)) alert(selectedCell+"-->Not a Number; Pls enter the value in numeric"); if(selectedCell=="") alert(selectedCell+"--->value can't be empty"); }
//On your editabel textBox, jus call the above function as
<input type="text" id="textBox1" runat="server" önclick="OnlyInteger(this)"/>
//hope u can get some way out
Here you go, full detail with sample:
Walkthrough: Validating Data in the Windows Forms DataGridView Control[^]
这篇关于验证datagridview中的特定单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文