.NET Framework 4.8
Telerik controls 2022 R1
Only one of two checkbox columns can be checked at any given time for any given row.
What I'm experiencing is when one column is checked and the other is selected, both are then unchecked including the one clicked.
Sample project illustrating the issue is attached and the event handler code is below.
What am I doing wrong? Any help would be most appreciated.
TIA
Event handler code:
private void Dgv_MenuItems_ValueChanged(object sender, EventArgs e)
{
if (_settingItemAvail)
{
return;
}
if (sender != null && sender is RadCheckBoxEditor checkBoxEditor)
{
var cell = checkBoxEditor.EditorElement.Parent as GridDataCellElement;
var cellName = cell.ColumnInfo.Name;
var row = cell.RowInfo;
if (row.Index < 0)
{
return;
}
_settingItemAvail = true;
switch (cellName)
{
case "Unavailable":
if (checkBoxEditor.Value.ToString() == "On")
{
if ((bool)dgv_MenuItems.Rows[row.Index].Cells["Available"].Value)
{
dgv_MenuItems.Rows[row.Index].Cells["Available"].Value = false;
}
}
break;
case "Available":
if (checkBoxEditor.Value.ToString() == "On")
{
if ((bool)dgv_MenuItems.Rows[row.Index].Cells["Unavailable"].Value)
{
dgv_MenuItems.Rows[row.Index].Cells["Unavailable"].Value = false;
}
}
break;
}
_settingItemAvail = false;
}
}