In GridControl esc key closes Combobox edit mode

i have used style.CellType = GridCellTypeName.ComboBox.  at CurrentCellStartEditing event... 

while i am editing combobox at runtime

while pressing escape key it closes comobox. ... 

i want to prevent escape key to close combobox edit mode... how can we do this..

i have even used GridControl1.WantEscapeKey = False but that also not works.



1 Reply

MA Mohanram Anbukkarasu Syncfusion Team March 8, 2022 10:53 AM UTC

Hi Singh,


You can achieve your requirement to cancel closing the dropdown while pressing ESC key on the ComboBox cell can be achieved by handling the CurrentCellShowingDropDown, CurrentCellCloseDropDown and CurrentCellKeyDown events as shown below.


Code example :


this.gridControl1.CurrentCellKeyDown += GridControl1_CurrentCellKeyDown;
this.gridControl1.CurrentCellShowingDropDown += GridControl1_CurrentCellShowingDropDown;
this.gridControl1.CurrentCellCloseDropDown += GridControl1_CurrentCellCloseDropDown;
private void GridControl1_CurrentCellCloseDropDown(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs e)
{
isDropDownOpened = false;
}
bool isDropDownOpened = false;
private void GridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
isDropDownOpened = true;
}
private void GridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
var grid = (sender as GridControl);
if (grid.Model[grid.CurrentCell.RowIndex, grid.CurrentCell.ColIndex].CellType == GridCellTypeName.ComboBox)
{
e.Handled = isDropDownOpened;
}
}


Please have a look at this sample and let us know if you require any other assistance from us.
Regards,
Mohanram A.



Loader.
Up arrow icon