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.
Syncfusion Feedback

strange text box ext behavior

Thread ID:

Created:

Updated:

Platform:

Replies:

57384 Mar 2,2007 03:20 PM UTC Mar 9,2007 08:48 PM UTC Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 2, 2007 03:20 PM UTC

Hi,
When I'm entering text into a text box and I hit the space bar, the cursor goes back to the beginning of the text string (as if I hit the 'Home' button) - How can I avoid this? I just want to keep typing forward.

Thanks,
Dimitri

Administrator [Syncfusion]
Replied On March 2, 2007 06:06 PM UTC

Hi Dimitri,

You can handle the CurrentCellKeyPress event and cancel it by setting the e.Handled to true when the 'SpaceBar' is pressed. Here is a code snippet.

void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 32)
{
GridCurrentCell cc = (sender as GridControl).CurrentCell;
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
cr.ControlText += " ";
cr.TextBox.SelectionLength = 0;
cr.TextBox.SelectionStart = cr.TextBox.Text.Length - 1;
e.Handled = true;
}
}

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 7, 2007 10:22 PM UTC

Hi, thanks,

This is for a text box, not a grid cell - does it still apply?

Thanks,


>Hi Dimitri,

You can handle the CurrentCellKeyPress event and cancel it by setting the e.Handled to true when the 'SpaceBar' is pressed. Here is a code snippet.

void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 32)
{
GridCurrentCell cc = (sender as GridControl).CurrentCell;
GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer;
cr.ControlText += " ";
cr.TextBox.SelectionLength = 0;
cr.TextBox.SelectionStart = cr.TextBox.Text.Length - 1;
e.Handled = true;
}
}

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 8, 2007 09:18 PM UTC

Hi Dimitri,

Please refer this and let me know if you are lookingi something different.
http://websamples.syncfusion.com/samples/Grid.Windows/GridKeyPressSapce/main.htm

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 8, 2007 10:21 PM UTC

Hi Haneef,
No - I mean a regular text box ext that I dragged onto a form - not a grid.

Thanks,
Dimitri

>Hi Dimitri,

Please refer this and let me know if you are lookingi something different.
http://websamples.syncfusion.com/samples/Grid.Windows/GridKeyPressSapce/main.htm

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 9, 2007 02:56 PM UTC

Haneef,
Also, if I try to put this handler on my grid (whose cell changes are reflected in the text box), I get this error:

Error 8 'Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyPressEventArgs' does not contain a definition for 'KeyChar'

>Hi Haneef,
No - I mean a regular text box ext that I dragged onto a form - not a grid.

Thanks,
Dimitri

>Hi Dimitri,

Please refer this and let me know if you are lookingi something different.
http://websamples.syncfusion.com/samples/Grid.Windows/GridKeyPressSapce/main.htm

Best regards,
Haneef

Administrator [Syncfusion]
Replied On March 9, 2007 08:48 PM UTC

Hi,

You can use the e.Inner.KeyChar to access the KeyChar from GridTableControlKeyPressEventArgs.

Best regards,
Haneef

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

;