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

Editing cell at clicked position

Hi,

When a user double-clicks a cell to edit its contents, normally he or she would expect the cursor to appear at the mouse click position.  In the GridControl it always seems to appear at the end of the string, as in this example:




In this case, I double-clicked the space between "Control" and "overview".

Copying the contents to Excel and doing the same thing, the cursor appears in the right spot:




To be consistent with Excel, is there a property available somewhere that switches to this behavior?


Thanks,
Thomas






8 Replies

KB Kanimozhi Bharathi Syncfusion Team June 22, 2015 12:41 PM UTC

Hi Thomas,

We have analyzed your query and based on your requirement, we have prepared a sample by customizing the existing GridCellTextBoxRenderer in the CustomTextBoxCellRendererExt class in which the cursor will be pointed to the location you have clicked in the cell. Please find the code snippet for your reference.

Please find the below sample attached below:

Sample Location: http://www.syncfusion.com/downloads/support/forum/119437/ze/WpfApplication81075722517

Please let us know if you need any clarifications.

Thanks

Kanimozhi B



TL Thomas Langley June 22, 2015 08:02 PM UTC

Hi Kanimozhi,

Thanks very much for the attached project.  With some tweaks to your code I have almost got it working the way I need (double-clicking after text should put caret at end, not before the letter) but there is one last problem that appears to be a bug.

If I type a longer string into one of the cells, such as "some really long string", the GetCharacterIndexFromPoint will return the wrong value when I click the cell.  In this case I clicked after "some" and it returned an index of 14:



Click after "some":

And the caret ends up here:




When I stretch the column out so it fits, then size it back, everything seems to work properly.

Please let me know if there is an easy workaround for this problem..


Regards,
Thomas




KB Kanimozhi Bharathi Syncfusion Team June 23, 2015 03:52 PM UTC

Hi Thomas,

We have analyzed your query and based on your requirement, we have prepared a sample by selecting the range of text in Textbox before getting the Caret Index.

Please find the below sample attached below:

Sample Location: http://www.syncfusion.com/downloads/support/forum/119437/ze/WpfApplication8-1534456929

Please let us know if you need any clarifications.

Thanks

Kanimozhi B



TL Thomas Langley June 23, 2015 04:09 PM UTC

Hi,

I tried the suggestion and it still picks the wrong index on the first attempt (subsequent attempts are working correctly). Note that  I had to change references to Syncfusion.Grid.WPF and Syncfusion.GridCommon.WPF as the provided solution appears to be using libraries I don't have - perhaps this is the reason?


Regards,
Thomas


KB Kanimozhi Bharathi Syncfusion Team June 24, 2015 06:45 PM UTC

Hi Thomas,

We have analyzed your query and based on your requirement, if you set the current cell activation by Double click, then textbox’s caret index will not be correctly set. You can set the current cell activation as single click by,

grid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell;

Please let us know if you need any clarifications.

Thanks

Kanimozhi B



TL Thomas Langley June 24, 2015 08:20 PM UTC

Hi Kanimozhi,

This is good to know.  However, I still need the activate mode to be double-click (we want it to behave just like Excel).  Should I submit a bug report on this?


Thanks,
Thomas


TL Thomas Langley June 26, 2015 10:06 PM UTC

Hi,

I was able to resolve the issue by calling CurrentCellUIElement.ScrollToHome() instead of CurrentCellUIElement.Select(0, 0).  GetCharacterIndexFromPoint now works correctly.

Thanks again for your assistance.

Regards,
Thomas


KB Kanimozhi Bharathi Syncfusion Team June 29, 2015 05:25 AM UTC

Hi Thomas,
 
Thanks for your update.
Please let us know if you need any further assistance.
 
Thanks
Kanimozhi B

Loader.
Live Chat Icon For mobile
Up arrow icon