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.

Editing cell at clicked position

Thread ID:

Created:

Updated:

Platform:

Replies:

119437 Jun 19,2015 05:52 PM Jun 29,2015 01:25 AM WPF 8
loading
Tags: GridControl
Thomas Langley
Asked On June 19, 2015 05:52 PM

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






Kanimozhi Bharathi [Syncfusion]
Replied On June 22, 2015 08:41 AM

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


Thomas Langley
Replied On June 22, 2015 04:02 PM

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



Kanimozhi Bharathi [Syncfusion]
Replied On June 23, 2015 11:52 AM

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


Thomas Langley
Replied On June 23, 2015 12:09 PM

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

Kanimozhi Bharathi [Syncfusion]
Replied On June 24, 2015 02:45 PM

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


Thomas Langley
Replied On June 24, 2015 04:20 PM

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

Thomas Langley
Replied On June 26, 2015 06:06 PM

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

Kanimozhi Bharathi [Syncfusion]
Replied On June 29, 2015 01:25 AM

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

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.

;