修复BtnDeleteTempDiff_Click方法,支持删除显示小三角但未完全选中的行

This commit is contained in:
zqm
2025-11-10 11:09:17 +08:00
parent 028ef29b32
commit af5cbbd06f

View File

@@ -557,7 +557,7 @@ namespace JoyD.Windows.CS
{
try
{
// 只删除选中的温差图例
// 检查是否有选中的行
if (dataGridViewTempDiff.SelectedRows.Count > 0)
{
// 获取选中行的索引
@@ -571,6 +571,20 @@ namespace JoyD.Windows.CS
dataGridViewTempDiff.Rows.RemoveAt(selectedRowIndex);
}
}
// 额外检查:如果没有选中的行但有当前单元格(显示小三角的情况)
else if (dataGridViewTempDiff.CurrentCell != null && dataGridViewTempDiff.CurrentCell.RowIndex >= 0)
{
// 获取当前单元格所在行的索引
int currentRowIndex = dataGridViewTempDiff.CurrentCell.RowIndex;
// 从数据集合中删除该行数据
if (currentRowIndex >= 0 && currentRowIndex < tempDiffData.Count)
{
tempDiffData.RemoveAt(currentRowIndex);
// 从DataGridView中删除该行
dataGridViewTempDiff.Rows.RemoveAt(currentRowIndex);
}
}
}
catch (Exception ex)
{