我有一个 GridControl 插入其中,直接修改到数据库中。
我有几个字段直接连接到一个表Patient
,我的 gridcontrol 字段之一id
是especielistas 1
Table
Specialist which has a 1:1 Relationship
Esp-> MuchosPacientes and this field shows you all
ID 专家and lets me do the main functions. But to eliminate me says no sender == null
,但实现了相同的代码,但针对 1 个事件KeyDown
并且它是否完全删除sender != null
,可以是:
private void gridControl1_EmbeddedNavigator_ButtonClick(
object sender,
NavigatorButtonClickEventArgs e)
{
if (e.Button.ButtonType == NavigatorButtonType.Edit
|| e.Button.ButtonType == NavigatorButtonType.EndEdit)
{
ColumnView view = gridControl1.FocusedView as ColumnView;
view.CloseEditor();
if (view.UpdateCurrentRow())
{
pacienteTableAdapter.Update(dBDataSet);
}
}
else if (e.Button.ButtonType == NavigatorButtonType.Remove)
{
if (MessageBox.Show("Desea eliminar?", "Confirmación", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
GridView view = sender as GridView; //AQUI ES EL ERROR
view.DeleteRow(view.FocusedRowHandle);
pacienteTableAdapter.Update(dBDataSet);
}
}
private void gridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
if (MessageBox.Show("Desea eliminar?", "Confirmación", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
GridView view = sender as GridView;
view.DeleteRow(view.FocusedRowHandle);
pacienteTableAdapter.Update(dBDataSet);
}
}