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.

GGC: Cell contents removed even after disabling AllowRemove

Thread ID:

Created:

Updated:

Platform:

Replies:

95190 Jun 25,2010 12:02 AM Jul 1,2010 07:19 AM Windows Forms 5
loading
Tags: GridControl
JBS Developers
Asked On June 25, 2010 12:02 AM

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


Jisha Joy [Syncfusion]
Replied On June 25, 2010 06:14 AM

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

JBS Developers
Replied On June 28, 2010 10:47 PM

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


Jisha Joy [Syncfusion]
Replied On June 29, 2010 06:03 AM

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

JBS Developers
Replied On July 1, 2010 12:37 AM

Hi Jisha,

Your latest solution works, thank you :)

Regards,

Magdalena

Jisha Joy [Syncfusion]
Replied On July 1, 2010 07:19 AM

Hi Magdalena,

Thank you for your update.

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.

;