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.

strange text box ext behavior

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 01:06 PM

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 05:22 PM

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 04:18 PM

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 05:21 PM

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 09:56 AM

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 03:48 PM

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.

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.

;