Tab to Grid for .Net Control on a Form

Article ID: 739
Last updated: 05 Jan, 2012
Article ID: 739
Last updated: 05 Jan, 2012
Revision: 1
Views: 1777
Posted: 05 Jun, 2006
by Meltreger B.
Updated: 05 Jan, 2012
by Meltreger B.
Problem

I'm trying to tab to an OG control on a form, that contains embedded .NET controls, but it never receives focus. I have the TabStop property set to true for the OG control and the TabOrder is set properly as well. However, it seems like, that using the tab key the OG control only receives focus if I already clicked on a cell with the mouse. And even then, it's not the OG control that receives focus but the embedded control belonging to the previously clicked cell.




Cause




Action

In our 1stgrid sample, add a few controls on a form with Grid, say  a button (TabInd =1), an edit (2) and a checkbox (4), then try following workaround:

 

private bool bTabtoGrid = false;

this.gridControl1.ProcessKeys += new Stingray.Grid.ProcessKeysEventHandler(this.gridControl1_ProcessKeys);

                 

 

protected override System.Boolean ProcessCmdKey (ref Message m ,

Keys keyData )

{

   if(keyData == Keys.Tab)

   {

if(this.GetNextControl(Control.FromHandle(m.HWnd),true)

                                         == gridControl1)

      {

            bTabtoGrid = true;

            return gridControl1.Focus();

      }

   }

   return base.ProcessCmdKey(ref m, keyData);

}

 

private void gridControl1_ProcessKeys(object sender, Stingray.Grid.ProcessKeysEventArgs e)

{

   if(e.Char == 9 && !bTabtoGrid)

   {

      GetNextControl(gridControl1,true).Focus();

      e.Handled = true;

   }

   else if (bTabtoGrid)

      bTabtoGrid = false;

}


This article was:   Helpful | Not helpful
Report an issue
Article ID: 739
Last updated: 05 Jan, 2012
Revision: 1
Views: 1777
Posted: 05 Jun, 2006 by Meltreger B.
Updated: 05 Jan, 2012 by Meltreger B.

Others in this category