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.

Excel Cell Click Behaviour.

Thread ID:

Created:

Updated:

Platform:

Replies:

118722 Apr 3,2015 08:47 AM Apr 7,2015 10:48 PM WPF 1
loading
Tags: GridDataControl
Basavaraj Angadi
Asked On April 3, 2015 08:47 AM


Hi,
 i am facing issue wrt to Excel Click.

Problem  : Double Click on cell then cursor should point to to the letter where I am clicked. This is exactly same behavior in Excel Cell text Selection.

I am using the below code,

this.grid.Model.Options.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell | GridCellActivateAction.PositionCaret;

with above code change, cell gets actvated on double click but cursor will be pointed to end of the content on right side.

But I need , Double Click on the Cell and Cursor should point to the exact position where I am clicked. Exact feature like excel cell text selection



Jayapradha S [Syncfusion]
Replied On April 7, 2015 10:48 PM

Hi Basavaraj,

Thank you for using Syncfusion products.

We have analyzed your requirement and you can placed the cursor position where you clicked like in Excel by using PreviewMouseLeftButtonDown and CurrentCellStartEditing Event as shown in the below code snippet,


Code Snippet:

void grid_CurrentCellStartEditing(object sender, Syncfusion.Windows.ComponentModel.SyncfusionCancelRoutedEventArgs args)

{

if (doubleClickArgs != null)

{

this.Dispatcher.BeginInvoke(new Action(SetCursorPosition),System.Windows.Threading.DispatcherPriority.ApplicationIdle);

}

}


void grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)

{

if(e.ClickCount==1)

doubleClickArgs=e;

else

doubleClickArgs=null;

}

private MouseButtonEventArgs doubleClickArgs = null;


private void SetCursorPosition()

{

GridCurrentCell cc = this.grid.Model.CurrencyManager.CurrentCell;

if (cc.Renderer.CurrentCellUIElement is TextBox)

{

TextBox tb = cc.Renderer.CurrentCellUIElement as TextBox;

if (doubleClickArgs != null)

{

Point pt = doubleClickArgs.GetPosition(tb);

tb.SelectionStart = tb.GetCharacterIndexFromPoint(pt, true) + 1;

tb.SelectionLength = 0;

}

doubleClickArgs = null;

}
}


We have prepared a sample to achieve your requirement and please find the sample from the below location,

Sample Link: GridDataControlsample.zip

Kindly let us know if this solution helps you.

Regards,
Jayapradha

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.

;