Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
816 | Aug 21,2002 03:08 AM UTC | Aug 26,2002 09:12 AM UTC | WinForms | 6 |
![]() |
Tags: GridControl |
private void gridControl1_CurrentCellDeactivating(object sender, System.ComponentModel.CancelEventArgs e)
{
if(this.gridControl1.CurrentCell.IsEditing)
this.gridControl1.CurrentCell.EndEdit();
}
public class MyGridControl : GridControl { //needed to handle all tabs except active border edit cell protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e) { if((e.KeyData & Keys.KeyCode) == Keys.Tab && MoveToNextCell()) return; base.OnKeyDown(e); } //this is needed to handle tab key on active cell at a border... protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m) { if((Keys)((int)m.WParam) == Keys.Tab) { if(MoveToNextCell()) return true; } return base.ProcessKeyPreview(ref m); } private bool MoveToNextCell() { bool b = false; GridDirectionType direction = ((Control.ModifierKeys & Keys.Shift) == 0) ? GridDirectionType.Right: GridDirectionType.Left ; int row = this.CurrentCell.RowIndex; int col = this.CurrentCell.ColIndex; if(direction == GridDirectionType.Right) col++; else col--; if(!this.CurrentCell.QueryNextEnabledCell(direction, ref row, ref col)) { if(direction == GridDirectionType.Right && this.ColCount == this.CurrentCell.ColIndex && this.RowCount > this.CurrentCell.RowIndex) { row = this.CurrentCell.RowIndex + 1; col = 1; if(this.CurrentCell.QueryNextEnabledCell(direction, ref row, ref col)) { this.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView); b = true; } } else if(direction == GridDirectionType.Left && 1 == this.CurrentCell.ColIndex && this.CurrentCell.RowIndex > 1) { row = this.CurrentCell.RowIndex - 1; col = this.ColCount; if(this.CurrentCell.QueryNextEnabledCell(direction, ref row, ref col)) { this.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView); b = true; } } } return b; } }
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.
This page will automatically be redirected to the sign-in page in 10 seconds.