[英]Excel: How to lock a cell based on another cell in the same row
I am working on export excel sheet using Devexpress library- Spreadsheet in c#.我正在使用 Devexpress 库 - c# 中的电子表格导出 excel 表。
I have 2 columns, 1st column with a dropdown (True/False) and 2nd column is just a text field.我有 2 列,第 1 列带有下拉列表(真/假),第 2 列只是一个文本字段。 If row has 1st column selected as True then it should lock the 2nd column and not allow to enter any values in it.
如果行的第一列选择为真,那么它应该锁定第二列并且不允许在其中输入任何值。
Was trying this ( https://docs.devexpress.com/WPF/DevExpress.Xpf.Spreadsheet.SpreadsheetControl.CellValueChanged ) event to catch and do my logic but didn't had any luck.正在尝试这个( https://docs.devexpress.com/WPF/DevExpress.Xpf.Spreadsheet.SpreadsheetControl.CellValueChanged )事件来捕捉并执行我的逻辑,但没有任何运气。
Need help..需要帮忙..
You can use CellBeginEdit
event您可以使用
CellBeginEdit
事件
void spreadsheetControl1_CellBeginEdit(object sender, SpreadsheetCellCancelEventArgs e) {
if (e.ColumnIndex == 1) {
var cellValue = e.Worksheet[e.RowIndex, 0].Value;
e.Cancel = cellValue.IsBoolean && cellValue.BooleanValue;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.