We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Deleting combobox text

Thread ID:

Created:

Updated:

Platform:

Replies:

78908 Jan 9,2009 03:43 PM Jan 12,2009 01:58 AM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 9, 2009 03:43 PM

I am trying to prevent the user from deleting the text in a combobox. The style is autocomplete, exclusive is set to true, but the user can still select the text inside and delete it using the delete key, backspace key, or any combination of these keys with control, alt, shift key. The CurrentCellDeleting event doesn't seem to trap this.

Also, if you put control inside the combobox and hit Control+Delete, the entire combobox disappears. How do i prevent this as well.

I am using the GridControl, version 5.2.0.25

Thanks,
Julie


Jisha Joy [Syncfusion]
Replied On January 12, 2009 01:58 AM

Hi Julie,

We appreciate your interest in Syncfusion products.

The mentioned issues can be avoided by handling CurrentCellDeleting and CurrentCellKeyDown events. Please see the code:


this.gridControl1.CurrentCellDeleting += new CancelEventHandler(gridControl1_CurrentCellDeleting);
this.gridControl1.CurrentCellKeyDown += new KeyEventHandler(gridControl1_CurrentCellKeyDown);


void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
bool ctl = (e.KeyData & Keys.Control) != 0;

bool del = (e.KeyData & Keys.Delete) != 0;

if (ctl && del) // Check for CTRL+del
{
e.Handled = true;
}
}



void gridControl1_CurrentCellDeleting(object sender, CancelEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
if (this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "ComboBox")
{
e.Cancel = true;
}
}

Regards,
Jisha


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;