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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Manually setting cursor/caret postion.

Thread ID:

Created:

Updated:

Platform:

Replies:

17291 Aug 5,2004 09:00 AM UTC Aug 5,2004 09:30 AM UTC WinForms 1
loading
Tags: GridControl
Martin
Asked On August 5, 2004 09:00 AM UTC

Hi I''ve got a problem where I am manually calling .BeginEdit on a cell to get it into edit mode, but I need to specify where the user starts typing within the cell text by specifying the caret position. Any ideas how I can go about this? Thanks Martin

Administrator [Syncfusion]
Replied On August 5, 2004 09:30 AM UTC

One way you can do this is to get the renderer for the currentcell, and then if it is a textbox, set the SelectionStart and Selection.Len. Here is a snippet that positions the cursor at the end of the text in CurrentCellStartEditing.
private void gridControl1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e)
{
	GridTextBoxCellRenderer tbr = this.gridControl1.CurrentCell.Renderer as GridTextBoxCellRenderer;
	if(tbr != null)
	{
		tbr.TextBox.SelectionStart = tbr.TextBox.Text.Length;
		tbr.TextBox.SelectionLength = 0;
	}
}

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.

Warning Icon 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.Close Icon

;