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.

Unexpected DataBoundGrid Cell Editing Behavior

Thread ID:

Created:

Updated:

Platform:

Replies:

14819 Jun 5,2004 05:28 AM Dec 28,2007 07:10 PM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 5, 2004 05:28 AM

In the DataBoundGrid: 1) When editing within a cell, press the delete key with the intent to delete some characters in the cell, however, the entire row is deleted. 2) In a cell with drop down multi-column GridList control that has both a display memeber and value, try backspacing over the characters. Sometimes, the bacspaces until just three characters remain and then stops. Other times, the backspace doesn''t work at all unless the characters are highlighted first. As described in 1), if you press anytime it deletes the row as described in 1), above. Do you see this same behavior? Do I have to trap events to change this? Thanks to the Syncfusion Team --Kenton

Administrator [Syncfusion]
Replied On June 5, 2004 06:53 AM

1) Do you have ListBoxSelectionMode set to something other than none? If so, rows will be selected in this mode, and if you press the delete key with rows selected, the grid deletes them. Try turning off the selection mode and I think you will see teh delete key work the way you expect. If you want to keep the selection mode, then you can handle the RowsDeleting event, cancel the delete and delete the text yourself. Here is a rough snippet that you may have to adjust for different celltypes in your grid.
private void gridDataBoundGrid1_RowsDeleting(object sender, Syncfusion.Windows.Forms.Grid.GridRowRangeEventArgs e)

{

	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;

	if(cc.IsEditing)

	{

		e.Cancel = true;

		GridTextBoxControl gtbc = cc.Renderer.Control as GridTextBoxControl;

		if(gtbc != null)

			gtbc.SelectedText = "";

	}

}
2) Do you have the DropDownStyle set to AutoComplete? If so, you are forcing the grid to autocomplete word after the backspace which will likely be the same selection. Try setting the DropDownStyle to Editiable. That will still autocomplete, but also lets you type values not in the list whic means it will let you backspace over text even if there is no match.

Kenton Hensley
Replied On June 5, 2004 08:23 AM

Smack-on on both counts! 1) Regarding Multi-selection mode, I was under the impression that multi-select for ListBoxSelectionMode had to be on to allow you to select rows. Now I see that this is aimed at selecting multiple ranges of cells. With ListBoxSelectionMode = None and using the row selectors in Column[0], you are still able to select multiple rows. I do not need to allow selection of muliple cell ranges, just multiple row ranges. 2) Setting to editable provides the required behavior. Thank you very much Clay, --Kenton

Tim Neumark
Replied On October 22, 2007 10:21 AM

I don't think this works completely. This implementation deletes the entire contents of the cell; I only want to delete a few letters.

Cell value:
- ABCDEFGH

I want to delete "D". How can I do it? With your method, the whole cell or the whole row is deleted. I want to delete one letter!

If nothing else, it would be helpful to get the position of the cursor within the cell so that I could just modify the index of the string.

Please help! Thanks

Rajagopal [Syncfusion]
Replied On December 28, 2007 07:10 PM

Hi Tim,

Please try the following code in the RowsDeleting event of the GridDataBoundGrid, this will help you in deleting only the character to the right when the delete key is pressed.

void gridDataBoundGrid1_RowsDeleting(object sender, GridRowRangeEventArgs e)
{
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
if (this.gridDataBoundGrid1.Model.Selections.Ranges.ActiveRange.IsRows && cc.IsEditing)
{
e.Cancel = true;
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
if (cr != null)
{
cr.TextBox.Select(cr.TextBox.SelectionStart, 1);
cr.TextBox.Text = cr.TextBox.Text.Replace(cr.TextBox.SelectedText, "");
cr.TextBox.SelectionStart = cr.TextBox.TextLength;
}
}
}

Let us know if you have any other questions.

Thanks for using Syncfusion Products.

Regards,
Rajagopal


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.

;