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 a range of cells

Thread ID:

Created:

Updated:

Platform:

Replies:

60036 Apr 26,2007 11:54 AM May 2,2012 05:25 AM Windows Forms 3
loading
Tags: GridControl
Kyle DeVoe
Asked On April 26, 2007 11:54 AM

We are using a cell activation of Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.SelectAll;

With the behaviour, when you enter a cell, it starts editing immediately.

When the user selects a range of cells and deletes, it currently only deletes the contents of the CurrentCell (the one in edit mode). I've tried calling CurrentCell.EndEditing() before the delete is processed, but that did not fix it.

I would like the deletion of a range to work the way it does when Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.None;

Thank you,
Kyle

haneefm [Syncfusion]
Replied On April 26, 2007 01:46 PM

Hi Kyle,

One way you can do this by handling the CurrentCellKeyDown event of the grid and call the ClearCells method to delete the content from the selected cells in a grid. Here is a code snippet.

private void grid_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if(e.KeyData == Keys.Delete)
this.grid.Model.ClearCells(this.grid.Model.SelectedRanges,false);
}

Best regards,
Haneef

Fabio Cavalcante
Replied On April 11, 2012 06:13 PM

And how can i move the left over content to the deleted cell?

e.g

Having A1, A2, A3. If i remove A2, A3 should be placed at A2.

THANKS.


Mercy C [Syncfusion]
Replied On May 2, 2012 05:25 AM

Hi Fabio,

Thanks for update.

To move the left over cell contents, please make use of "Rows.RemoveRange()" method to remove the empty space.

void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Delete)
{
this.gridControl1.Model.ClearCells(this.gridControl1.Model.SelectedRanges, false);
this.gridControl1.Rows.RemoveRange(this.gridControl1.Model.SelectedRanges.ActiveRange.Top, this.gridControl1.Model.SelectedRanges.ActiveRange.Bottom);
}
}

Please refer to the sample in the following link
http://www.syncfusion.com/downloads/Support/DirectTrac/93412/WindowsFormsApplication91239196294.zip

Regards,
Mercy.C


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.

;