和Excel一样,除了设置cell的锁定,还要设置sheet 的保护。
- gcSpreadSheet1.Sheets[0].Cells[1, 1].Locked = false;
- gcSpreadSheet1.Sheets[0].Cells[1, 1].Text = "Locked";
- gcSpreadSheet1.Sheets[0].Columns[3].Locked = false;
- gcSpreadSheet1.Sheets[0].Rows[5].Locked = false;
- gcSpreadSheet1.Protect = true;
- gcSpreadSheet1.Sheets[0].Protect = true;
- gcSpreadSheet1.Invalidate();
- private void button1_Click(object sender, RoutedEventArgs e)
- {
- gcSpreadSheet1.Sheets[0].Cells[1, 1].ResetLocked();
- gcSpreadSheet1.Invalidate();
- }
复制代码 |