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. Image for the cookie policy date
close icon

GGC: Cell contents removed even after disabling AllowRemove

Hi there,

There seem to be inconsistent behaviours on selecting a row and pressing the Delete key by setting TableDescriptor.AllowRemove and TableOptions.AllowSelection on GridGroupingControl.

- Scenario #1:
TableDescriptor.AllowRemove = true;
TableOptions.AllowSelection = (GridSelectionFlags.Row | GridSelectionFlags.Cell) | GridSelectionFlags.AlphaBlend;
--> Selecting a row and pressing Delete key will remove the entire row.

- Scenario #2:
TableDescriptor.AllowRemove = true;
TableOptions.AllowSelection = GridSelectionFlags.None;
--> Selecting a row and pressing Delete key wont remove the row.

- Scenario #3:
TableDescriptor.AllowRemove = false;
TableOptions.AllowSelection = GridSelectionFlags.None;
--> Selecting a row and pressing Delete key wont remove the row.

- Scenario #4:
TableDescriptor.AllowRemove = false;
TableOptions.AllowSelection = (GridSelectionFlags.Row | GridSelectionFlags.Cell) | GridSelectionFlags.AlphaBlend;
--> Selecting a row (by clicking the left most cell) and pressing Delete key will not remove the row, BUT this will remove all of the editable cell contents.

In regards to scenario #4, is there a way to keep my AllowSelection setting and pressing Delete key to not remove the row or all of the row cell contents?
Note that I still want to be able to edit each record cells so I cant make them read-only and I stil want the ability to click on each cell and press Delete to remove the content of that cell only.
But when I click the left most cell and have the entire row selected, I don't want pressing Delete to remove all of the cell contents.

Thank you,

Magdalena


5 Replies

JJ Jisha Joy Syncfusion Team June 25, 2010 10:14 AM UTC

Hi Magdalena,

You could handle TableControlCurrentCellKeyDown event and set e.Inner.Handled = true; when delete key is pressed.

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if (e.Inner.KeyCode == Keys.Delete)
{
e.Inner.Handled = true;
}
}


Please let me know if this helps.

Regards,
Jisha


JD JBS Developers June 29, 2010 02:47 AM UTC

Hi and thanks for the reply.

The solution provided indeed prevent user from deleting the entire row, but it also prevents me from deleting the cell content when I click inside the cell and press "Delete" key with the intention of deleting a character.

What I want is in scenario #4, when pressing the left most cell (this will select the entire row) and press Delete, none of the editable cell content on the selected row to get deleted.
But when the user click on any editable cell and press Delete key, a character (within the cell content) to be deleted as per normal.

Thank you,

Magdalena



JJ Jisha Joy Syncfusion Team June 29, 2010 10:03 AM UTC

Hi Magdalena,

Please use the following modified code to achieve the desired behavior.

void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
if (e.TableControl.CurrentCell.ColIndex == 0)
{
if (e.Inner.KeyCode == Keys.Delete)
{
e.Inner.Handled = true;
}
}

}

Regards,
Jisha


JD JBS Developers July 1, 2010 04:37 AM UTC

Hi Jisha,

Your latest solution works, thank you :)

Regards,

Magdalena


JJ Jisha Joy Syncfusion Team July 1, 2010 11:19 AM UTC

Hi Magdalena,

Thank you for your update.

Regards,
Jisha

Loader.
Live Chat Icon For mobile
Up arrow icon