Esempio n. 1
0
        internal void SynchScrollPosition(bool synchMain)
        {
            Point pos;

            // optionally synchronize X scroll position on the main grid
            if (synchMain)
            {
                pos   = _frz.ScrollPosition;
                pos.Y = _main.ScrollPosition.Y;
                _main.ScrollPosition = pos;
            }

            // syncronize X scroll position of the frozen grid with main
            pos   = _main.ScrollPosition;
            pos.Y = -64000;
            _frz.ScrollPosition = pos;

            // update everything right away
            _main.Update();
            _frz.Update();
        }
Esempio n. 2
0
        // save a bool with several sheets in it
        void _btnMultiSheet_Click(object sender, System.EventArgs e)
        {
            // choose file
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.DefaultExt = "xls";
            dlg.FileName   = "*.xls";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // delete file if it's already there
            if (File.Exists(dlg.FileName))
            {
                File.Delete(dlg.FileName);
            }

            // prepare to load data from database
            string mdbfile = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\ComponentOne Samples\Common\c1nwind.mdb";
            string conn    = @"provider=microsoft.jet.oledb.4.0;data source=" + mdbfile + ";";

            System.Data.OleDb.OleDbDataAdapter da;

            // save several sheets
            string[] tables = "Categories|Products|Employees|Customers|Orders".Split('|');
            foreach (string table in tables)
            {
                // load data into grid
                string sql = "select * from " + table;
                da = new System.Data.OleDb.OleDbDataAdapter(sql, conn);
                DataTable dt = new DataTable();
                da.Fill(dt);
                _flex.DataSource = dt;
                _flex.Update();

                // save into a sheet
                _flex.SaveExcel(dlg.FileName, table, FileFlags.VisibleOnly | FileFlags.IncludeFixedCells);
            }
        }