How to I force the LEFT/RIGHT arrow key to skip the plus/minus button.

How do I force the LEFT or RIGHT arrow key to skip the plus/minus button.

3 Replies

AD Administrator Syncfusion Team December 14, 2006 01:56 PM UTC

Hi James,

You can skip the GroupCaptionPlusMinus button by handling the TableControlKeyDown event. In the event, you can move CurrentCell accordingly depending on the GroupCaptionPlusMinus. The following is the code snippet

>>>>>>>>>>>>>>>>>>>>>>>>>>
private void gridGroupingControl1_TableControlKeyDown(object sender, GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if(e.Inner.KeyCode == Keys.Right)
{
GridTableCellStyleInfo info = this.gridGroupingControl1.Table.TableModel[cc.RowIndex,cc.ColIndex];
if (info != null && info.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionPlusMinusCell) //cs != null ) //&& cs.GroupLevel > 0)
{
e.Inner.Handled = true;
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex+1);
}
}
else if(e.Inner.KeyCode == Keys.Left)
{
GridTableCellStyleInfo info = this.gridGroupingControl1.Table.TableModel[cc.RowIndex,cc.ColIndex];
if (info != null && info.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionPlusMinusCell) //cs != null ) //&& cs.GroupLevel > 0)
{
e.Inner.Handled = true;
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex-1);
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>

In case, if you need to avoid expand and collapse of group on Right arrow key. You can use the following code snippet.

>>>>>>>>>>>>>>>>>>>>>>>>>>
private void gridGroupingControl1_TableControlKeyDown(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if(e.Inner.KeyCode == Keys.Up)
{
e.Inner.Handled = true;
if(this.gridGroupingControl1.Table.TableModel.GetDisplayElementAt(cc.RowIndex-1) is CaptionRow)
{
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex-1, cc.ColIndex);
}
}
if(e.Inner.KeyCode == Keys.Down)
{
e.Inner.Handled = true;
if(this.gridGroupingControl1.Table.TableModel.GetDisplayElementAt(cc.RowIndex+1) is CaptionRow)
{
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex+1, cc.ColIndex);
}
}
if(e.Inner.KeyCode == Keys.Right)
{
e.Inner.Handled = true;
CaptionRow cs = this.gridGroupingControl1.Table.TableModel.GetDisplayElementAt(cc.RowIndex) as CaptionRow;
if (cs != null && cs.GroupLevel > 0)
{
Group g = cs.ParentGroup;
if (g.IsExpanded)
{
g.IsExpanded = !g.IsExpanded;
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex+1);
}
}
}
if(e.Inner.KeyCode == Keys.Left)
{
e.Inner.Handled = true;
if(this.gridGroupingControl1.Table.TableModel.GetDisplayElementAt(cc.RowIndex+1) is CaptionRow)
{
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex-1);
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>

Kindly try it and let us know if you need assistance or a demo sample.
Have a nice day.

Best regards,
Madhan


JB James Blibo December 21, 2006 01:25 AM UTC

Both solutions not working...

With the first, when I hit a captionsummary cell , I get stuck in that cell.;

Fir the second, I get stuck in any cell and can't move.


AD Administrator Syncfusion Team December 22, 2006 07:09 AM UTC

Hi James,

Please update us more details or a video clip on your requirement. Is your requirement to avoid the navigation over the caption plus/minus on right or left key navigation or do you need to avoid expand / collapse on right and left key?

The following is the sample using your grid settings which demonstrates the way to avoid expand / collapse caption group on Left/Right key navigation.
GGC_Navigation_22Dec06.zip

Thank you for being patience.
Have a nice day.

Best regards,
Madhan

Loader.
Up arrow icon