strange text box ext behavior

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

6 Replies

AD Administrator Syncfusion Team 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


AD Administrator Syncfusion Team 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


AD Administrator Syncfusion Team 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


AD Administrator Syncfusion Team 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


AD Administrator Syncfusion Team 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


AD Administrator Syncfusion Team March 9, 2007 08:48 PM UTC

Hi,

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

Best regards,
Haneef

Loader.
Up arrow icon