简体   繁体   English

Excel:如何根据同一行中的另一个单元格锁定一个单元格

[英]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.

相关问题 Selenium C#-如何单击基于同一行中另一个单元格的单元格中的链接? - Selenium C# - How to click on a link in a cell based on another cell in the same row? 如何单击基于同一行C#asp.net中另一个单元格的链接 - How to click on a link based on another cell in same row C# asp.net C# Winforms如何基于同一行上的另一个单元格从Datagridview获取文本到label? - C# Winforms how to get text from Datagridview to a label based on another cell on the same row? 根据aspxgridview中一行中的另一个单元格值禁用一个单元格 - disable a cell based on another cell value in a row in aspxgridview 当同一行中的另一个单元格发生更改时,如何更改DataGridView Cell的值? - How to change the value of DataGridView Cell when another cell in the same row changed? 单元格中的Excel行 - Excel row in cell Excel如何基于单元格witdh使文本适合单元格 - Excel how to fit text in cell, based on cell witdh 如何将 WPF 网格单元复制到同一网格中的另一个单元 - How to copy WPF grid cell to another cell in the same grid 如何使用 C# 在 Excel.xlsx 文件中基于行列组合在单元格中输入值? - How to enter a value in a cell based on row-column combination in an Excel .xlsx file using C#? 根据同一行中单元格的值显示和隐藏gridview按钮 - Showing and hiding of gridview button based on the value of a cell in the same row
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM