using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Mesnac.Action.Base; using Mesnac.Controls.Base; using System.Windows.Forms; using Mesnac.Codd.Session; namespace Mesnac.Action.Default.SynchroData { public class NextRow : DatabaseAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 #region 限定只对相同DataSource的数据表进行操作 string mcDataSourceID = String.Empty; if (runtime.Sender is Mesnac.Controls.Base.IBaseControl) { mcDataSourceID = (runtime.Sender as Mesnac.Controls.Base.IBaseControl).MCDataSourceID; } #endregion foreach (IBaseControl cgrid in GetAllMCControls()) { if (!String.IsNullOrEmpty(mcDataSourceID) && cgrid.MCDataSourceID != mcDataSourceID) { continue; } DataGridView grid = runtime.Sender as DataGridView; if (grid == null) { if (cgrid is DataGridView) { grid = cgrid as DataGridView; } } if (grid == null) { continue; } int index = -1; foreach (DataGridViewRow row in grid.SelectedRows) { row.Selected = false; index = row.Index; } index++; if (grid.Rows.Count > index) { grid.Rows[index].Selected = true; } else if (grid.Rows.Count > 0) { grid.Rows[grid.Rows.Count - 1].Selected = true; } if (runtime.Sender is DataGridView) { return; } } } } }