
1.首先打开Excel,打开自己需要的表格,可以看到这份表格已经被保护了。无法进行更改的 *** 作。
2.此时我们无法进行某些 *** 作,上方的很多选项都是灰色烂慎的,无法修改。
3.下面我们需要点击上方工具栏中的“审阅”。
4.接着可以看到右侧有“撤销工作表保护”的选项,我们凯历贺点击一下。
5.最后输入我们保护表格时设置的密码即可解除保盯派护。
6.这时再看上方工具栏里,“撤销工作表保护”的选项已经没有了,说明表格的保护情况已经解除。
namespace WinFormCSharp{
public partial class Form1 : Form
{
DataGridView dv = new DataGridView()
DataTable dt = new DataTable()
public Form1()
{
InitializeComponent()
}
private void Form1_Load(object sender, EventArgs e)
{
dv.Parent = this
dv.Dock = DockStyle.Fill
dv.DataError += new DataGridViewDataErrorEventHandler(dv_DataError)
dv.CellValidated +=new DataGridViewCellEventHandler(dv_CellValidated)
dt.Columns.Add("money", typeof(decimal))
dt.Rows.Add(10.2m)
dv.DataSource = dt
dt.AcceptChanges()
}
void dv_CellValidated(object sender, DataGridViewCellEventArgs e)
{
//通过了检测,保存上一次的数值
dt.AcceptChanges()
}
void dv_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
//出错时候,自动更正为默认值
MessageBox.Show("输入数据错误,自李察动恢复到原来数值!")
dv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = dt.Rows[e.RowIndex][e.ColumnIndex, DataRowVersion.Original] //则扰缓孙模恢复成默认数值
e.Cancel = false
}
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)