예제 #1
0
        /// <summary>
        /// Displays specified sheet in the grid
        /// </summary>
        /// <param name="sh">Reference to sheet object</param>
        protected void ActivateSheet(S_DataSheet sh)
        {
            if (sh == null)
            {
                return;
            }
            active_sheet = sh;

            foreach (Control c in flowLayoutPanel1.Controls)//make all sheets' apperence standart
            {
                if (c is Button)
                {
                    (c as Button).FlatStyle = FlatStyle.Standard;
                    (c as Button).ForeColor = Color.Black;
                }
            }

            //highlight active sheet
            sh.title_button.FlatStyle = FlatStyle.Flat;
            sh.title_button.ForeColor = Color.Blue;

            //adjust data binding of the underlying DataGridView control
            dataGridView1.AutoGenerateColumns = true;
            if (sh.data != null)
            {
                dataGridView1.DataSource = sh.data;
            }
        }
예제 #2
0
        /// <summary>
        /// Activates specified sheet in this control instance
        ///
        /// </summary>
        /// <param name="index">Sheet number</param>
        public void SetActiveSheet(int index)
        {
            if (index <= 0)
            {
                throw new ArgumentException("sheet number must be positive");
            }

            this.active_sheet = sheets[index - 1];
        }
예제 #3
0
        /// <summary>
        /// Creates the new sheet and adds it to this data grid control
        /// </summary>
        /// <param name="name">Optional sheet name</param>
        protected void NewSheet(string name = "")
        {
            if (sheets == null)
            {
                sheets = new List <S_DataSheet>(6);
            }
            if (name == null)
            {
                name = "";
            }

            S_DataSheet sh = new S_DataSheet();
            int         c  = sheets.Count + 1;
            DataColumn  col;
            DataRow     row;

            if (name.Trim().Length == 0)
            {
                sh.name = "Sheet " + c.ToString();
            }
            else
            {
                sh.name = name;
            }

            //create table with empty rows an columns
            sh.data = new DataTable(sh.name);
            for (int i = 1; i <= 50; i++)
            {
                col = new DataColumn(i.ToString());
                sh.data.Columns.Add(col);
            }

            for (int i = 1; i <= 200; i++)
            {
                row = sh.data.NewRow();
                sh.data.Rows.Add(row);
            }

            //create title button associated with this sheet and add it into the grid
            sh.title_button        = new Button();
            sh.title_button.Text   = sh.name;
            sh.title_button.Height = flowLayoutPanel1.Height - 4;
            sh.title_button.Width  = 70;
            sh.title_button.Click += button_Click;
            sh.title_button.Tag    = sh;
            this.sheets.Add(sh);
            flowLayoutPanel1.Controls.Add(sh.title_button);
        }
예제 #4
0
        /// <summary>
        /// Event fired when user clicks a button associated with certain sheet
        /// </summary>
        private void button_Click(object sender, EventArgs e)
        {
            Button butt = (Button)sender;

            if (butt == null)
            {
                return;
            }
            S_DataSheet sh = (S_DataSheet)butt.Tag;

            if (sh == null)
            {
                return;
            }
            ActivateSheet(sh);//activate sheet associated with this button
        }