编辑GridView时只能输入数字教学文案.doc

编辑GridView时只能输入数字教学文案.doc

ID:57164360

大小:18.00 KB

页数:4页

时间:2020-08-05

编辑GridView时只能输入数字教学文案.doc_第1页
编辑GridView时只能输入数字教学文案.doc_第2页
编辑GridView时只能输入数字教学文案.doc_第3页
编辑GridView时只能输入数字教学文案.doc_第4页
资源描述:

《编辑GridView时只能输入数字教学文案.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、编辑GridView时只能输入数字精品文档usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceWindowsFormsApplication4{publicpartialclassForm2:Form{publicForm2(){I

2、nitializeComponent();}privatevoidForm2_Load(objectsender,EventArgse){//TODO:这行代码将数据加载到表“testDataSet3.salary”中。您可以根据需要移动或移除它。this.salaryTableAdapter.Fill(this.testDataSet3.salary);//TODO:这行代码将数据加载到表“testDataSet1.login”中。您可以根据需要移动或移除它。this.loginTableAdapter.Fill(this.testDataSet1.login);dataGrid

3、View1.Columns[0].ReadOnly=true;dataGridView1.Columns[4].ReadOnly=true;}privatevoiddataGridView1_CellEndEdit(objectsender,DataGridViewCellEventArgse){dataGridView1.Columns[0].ReadOnly=false;ints1=Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value);ints2=Convert.ToInt32(dataGridView1.Curren

4、tRow.Cells[2].Value);收集于网络,如有侵权请联系管理员删除精品文档ints3=Convert.ToInt32(dataGridView1.CurrentRow.Cells[3].Value);dataGridView1.CurrentRow.Cells[4].Value=s1+s2+s3;ints4=s1+s2+s3;SqlConnectionconn=newSqlConnection(@"Server=(local);IntegratedSecurity=True;"+"Database=Test");conn.Open();SqlCommandcomm=ne

5、wSqlCommand("updatesalaryset基本工资='"+s1+"',奖励='"+s2+"',全勤='"+s3+"',应发工资='"+s4+"'where员工姓名='"+dataGridView1.CurrentRow.Cells[0].ToString()+"'",conn);comm.ExecuteNonQuery();//MessageBox.Show("修改成功!");}privatevoiddataGridView1_KeyPress(objectsender,KeyPressEventArgse){//if(!char.IsDigit(e.KeyChar)

6、)//{//MessageBox.Show("sdfsdf");//e.Handled=true;//}}privatevoiddataGridView1_CellValidating(objectsender,DataGridViewCellValidatingEventArgse){if(e.ColumnIndex==1

7、

8、e.ColumnIndex==2

9、

10、e.ColumnIndex==3

11、

12、e.ColumnIndex==4){try{if(String.IsNullOrEmpty(e.FormattedValue.ToString())){}else{decimalval=

13、decimal.Parse(e.FormattedValue.ToString());}}catch(Exceptionex){dataGridView1.Rows[e.RowIndex].ErrorText="必须输入数字";收集于网络,如有侵权请联系管理员删除精品文档MessageBox.Show("请输入数字");e.Cancel=true;}}}}}收集于网络,如有侵权请联系管理员删除

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。