public virtual bool ReloadData()
        {
            Console.WriteLine("{0}: RefreshData", DateTime.Now.ToString("HH:mm:ss fff"));
            if (grid.DataSource == null)
            {
                return(false);
            }

            DataTable table = grid.GetDataView().Table;
            int       firstCellColumnIndex = grid.FirstDisplayedCell == null ? 0 : grid.FirstDisplayedCell.ColumnIndex;
            int       firstCellRowIndex    = grid.FirstDisplayedCell == null ? 0 : grid.FirstDisplayedCell.RowIndex;
            object    keyObj = grid.KeyObject;

            try
            {
                grid.DataSource = null;

                optionFolder.Clear();
                optionFolder.Load();

                colParams = new ColParams(this);
                colParams.Verify(table);
                //grid.BeginInvoke((MethodInvoker)(colParams.Save));
                Init();

                grid.DataSource = table.DefaultView;
                grid.SetSort(colParams.SortOrder);

                grid.BeginInvoke((MethodInvoker)(Save));

                return(true);
            }
            catch (Exception ex)
            {
                Lib.Win.Data.Env.WriteToLog(ex);
            }
            finally
            {
                if (grid.IsFine && grid.SelectRow(keyObj))
                {
                    try
                    {
                        while (firstCellColumnIndex > grid.ColumnCount - 1 && firstCellColumnIndex > -1)
                        {
                            firstCellColumnIndex--;
                        }
                        grid.FirstDisplayedCell = grid[firstCellColumnIndex, firstCellRowIndex];
                    }
                    catch { }
                    grid.DisplayCurrentRow();
                }
                else
                {
                    grid.CurrentCell = null;
                }
                grid.ResumeLayout();
            }

            return(false);
        }
        public virtual bool LoadData(DataTable dt)
        {
            try
            {
                Console.WriteLine("{0}: LoadData", DateTime.Now.ToString("HH:mm:ss fff"));
                grid.Enabled = false;
                grid.SuspendLayout();

                if (dt == null || dt.Rows == null || dt.Columns.Count < 1)
                {
                    grid.DataSource = null;
                    if (grid.Columns != null)
                    {
                        grid.Columns.Clear();
                    }
                }
                else
                {
                    colParams = new ColParams(this);
                    colParams.Verify(dt);
                    Reset = false;
                    Init();
                    grid.DataSource = dt.DefaultView;
                    grid.SetSort(colParams.SortOrder);
                    Save();
                }
            }
            catch (Exception ex)
            {
                Lib.Win.Data.Env.WriteToLog(ex);
                return(false);
            }
            finally
            {
                grid.CurrentCell = null;
                grid.ResumeLayout(true);
                grid.Enabled = true;
                grid.Invalidate();
            }
            return(true);
        }
        public virtual bool ReloadData(DataTable dt)
        {
            Console.WriteLine("{0}: ReloadData", DateTime.Now.ToString("HH:mm:ss fff"));
            if (grid == null)
            {
                return(false);
            }
            if (dt == null || dt.Rows == null || dt.Rows.Count == 0)
            {
                colParams       = null;
                grid.DataSource = null;
                if (grid.Columns != null)
                {
                    grid.Columns.Clear();
                }
                return(false);
            }

            object keyObj = grid.KeyObject;

            if (!grid.IsFine || colParams == null)
            {
                try
                {
                    grid.SuspendLayout();
                    if (grid.DataSource != null && dt.Rows.Count > 0)
                    {
                        grid.SetSilent();
                    }
                    return(LoadData(dt));
                }
                finally
                {
                    grid.RemoveSilent();
                    if (grid.IsFine)
                    {
                        if (!grid.SelectRow(keyObj))
                        {
                            grid.ClearSelection();
                            grid.CurrentCell = null;
                        }
                    }
                    else
                    {
                        grid.CurrentCell = null;
                    }
                    grid.ResumeLayout();
                }
            }

            int firstCellColumnIndex = grid.FirstDisplayedCell == null ? 0 : grid.FirstDisplayedCell.ColumnIndex;
            int firstCellRowIndex    = grid.FirstDisplayedCell == null ? 0 : grid.FirstDisplayedCell.RowIndex;

            try
            {
                grid.SuspendLayout();
                if (grid.DataSource != null && dt.Rows.Count > 0)
                {
                    grid.SetSilent();
                }
                grid.DataSource = dt.Rows.Count == 0 ? null : dt.DefaultView;
                if (grid.IsFine)
                {
                    try { grid.GetDataView().Sort = colParams.SortOrder; }
                    catch { grid.SetSort(colParams.SortOrder); }
                    try
                    {
                        while (firstCellColumnIndex > grid.ColumnCount - 1 && firstCellColumnIndex > -1)
                        {
                            firstCellColumnIndex--;
                        }
                        grid.FirstDisplayedCell = grid[firstCellColumnIndex, firstCellRowIndex];
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            {
                Lib.Win.Data.Env.WriteToLog(ex);
                return(false);
            }
            finally
            {
                grid.RemoveSilent();
                if (grid.IsFine)
                {
                    if (!grid.SelectRow(keyObj))
                    {
                        grid.ClearSelection();
                        grid.CurrentCell = null;
                    }
                }
                else
                {
                    grid.CurrentCell = null;
                }
                grid.ResumeLayout();
            }
            return(true);
        }