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

Typing into selected cell automatically selects first character

Hi,
when I write a character in a cell, where the cursor is not displayed, then this character is automatically selected. So when typing the next character, the first character is deleted. So I have to write the first character twice. Then it works OK again (note: the cell is just selected, but the cursor is not inside of the cell).

Note: this is not a standard behaviour of the grid. Normally when you start to write to the cell, the first character will not be selected (e.g. like in excel). But I maintain a large project, where a lot of settings were changed.

Please can you give some hint, where to look to change this behaviour?
Thank you, Dan

6 Replies

HA haneefm Syncfusion Team June 19, 2007 03:18 PM UTC

Hi Dan,

You can try setting

[c#]
this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.SetCurrent;

This will make sure the current cell gets activated as you cursor into the cell. This happens by default when you click on a cell. It doesn't select the cell text when you click on a cell.

Best regards,
Haneef


DD Daniel Dusek June 20, 2007 09:58 AM UTC

Hi Haneef,
in the project, there is alredy this property set to 'DblClickOnCell'. But I have tried to use the setting you have proposed, but with this setting the cell-text gets selected after I click on the cell, and some more 'unwanted' things happen to the cell :-). So this is not the propper solution for me.

Have you another idea, how can I manage this problem please?

Thank you, Dan


HA haneefm Syncfusion Team June 20, 2007 06:32 PM UTC

Hi Dan,

You can handle the CurrentCellActivated event of the grid and change the selected text of the cell using the TextBox.SelectionStart property from the GridTextBoxCellRenderer object. Below are the code snippet

private void gridControl1_CurrentCellActivated(object sender, System.EventArgs e)
{
GridControl t_grid = sender as GridControl;
GridTextBoxCellRenderer cr = t_grid.CurrentCell.Renderer as GridTextBoxCellRenderer;
if( cr != null )
{
if( cr.TextBox.Text != string.Empty || cr.TextBox.Text.Length > 0)
{
cr.TextBox.SelectionLength = 0;
cr.TextBox.SelectionStart = cr.TextBox.Text.Length;
}
}
}

Best regards,
Haneef


DD Daniel Dusek June 21, 2007 08:06 AM UTC

Hi Haneef,
I have implemented the current cell activated event handler, but it did not helped. My problem is, that the cell is active, the selection is of zero lenght, the cursor is not in the cell, and at this moment I press some key, e.g. 'A' and the letter 'A' is written to the current cell, but the letter 'A' is selected. When I press the key 'A', then the event current cell activated is not catched at all.

I have also tested the key-press event. There I have seen, that selection is of zero lenght at the time when the key-press is catched. So the first character is selected 'after' the key-press' event.

Do you have some more ideas plaese?

Thank you, Dan.


HA haneefm Syncfusion Team June 21, 2007 06:08 PM UTC

Hi Dan,

Thank you for your update.

I am not sure of what be might be causing this strange behavior without a working sample. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef


DD Daniel Dusek June 22, 2007 10:47 AM UTC

Hi Haneef,
I do not use the Syncfusion Hierarchical Grid it self, but I work with a wrapper. The wrapper allows to use the grid control within a managed c++ project.

I have found, that the wrapper is responsible for this behaviour. Another developer before me has chnaged the code of the wrapper somehow :-(.

Thank you for your help. I will now focus on the wrapper code, hopefully I can find the source of the behaviour there.

Regads Dan.

Loader.
Live Chat Icon For mobile
Up arrow icon