Ejemplo n.º 1
0
        private void EditTab_Click(object sender, EventArgs e)
        {
            using TabSettings tab = new TabSettings("Изменить вкладку", TabMarks.TabPages[TabMarks.SelectedIndex].Text, tables[TabMarks.SelectedIndex].type);

            tab.ShowDialog();

            if (tab.nameTab != "")
            {
                TabMarks.TabPages[TabMarks.SelectedIndex].Text = tab.nameTab;

                if (tab.type != tables[TabMarks.SelectedIndex].type)
                {
                    DialogResult quest = DialogResult.No;

                    if (tables[TabMarks.SelectedIndex].startEdit)
                    {
                        quest = MessageBox.Show("Вы сменили тип среднего балла, сохранить текущую таблицу?", "Сохранить?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    }

                    if (quest == DialogResult.Yes)
                    {
                        saveFile.PerformClick();
                    }

                    tables[TabMarks.SelectedIndex].type = tab.type;

                    ResetClass rst = new ResetClass(tables[TabMarks.SelectedIndex], tables[TabMarks.SelectedIndex].marks);

                    tables[TabMarks.SelectedIndex] = rst.Reset(tab.type);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddTabFunc(bool type = true, bool newTab = false)
        {
            if (!newTab)
            {
                using TabSettings tab = (tables == null ? null : new TabSettings("Создать вкладку", "Пример 1", type));

                if (tables != null)
                {
                    tab.ShowDialog();
                }

                tables ??= new List <MarksTable>();

                TabMarks.TabPages.Add(tab == null ? "Вкладка 1" : tab.nameTab);
                TabMarks.SelectedIndex = TabMarks.TabCount - 1;
                tables.Add(new MarksTable());

                DataGridView grid = new DataGridView
                {
                    Dock             = DockStyle.Fill,
                    ReadOnly         = false,
                    ContextMenuStrip = TableMenu,
                    AllowDrop        = true
                };

                grid.DragDrop    += DropFile;
                grid.DragEnter   += DragEnter;
                grid.CellEndEdit += (obj, ev) => CellFormating(obj, ev);


                TabMarks.TabPages[TabMarks.SelectedIndex].Controls.Add(grid);

                ResetClass rst = new ResetClass(tables[TabMarks.SelectedIndex], grid);

                tables[TabMarks.SelectedIndex] = rst.Reset(tab == null ? type : tab.type);
            }
            else
            {
                using TabSettings tab = new TabSettings("Создать вкладку", "Пример 1", type);

                TabMarks.TabPages.Add("Пример 1");
                TabMarks.SelectedIndex = TabMarks.TabCount - 1;
                tables.Add(new MarksTable());

                DataGridView grid = new DataGridView
                {
                    Dock             = DockStyle.Fill,
                    ReadOnly         = false,
                    ContextMenuStrip = TableMenu,
                    AllowDrop        = true
                };

                grid.DragDrop    += DropFile;
                grid.DragEnter   += DragEnter;
                grid.CellEndEdit += (obj, ev) => CellFormating(obj, ev);


                TabMarks.TabPages[TabMarks.SelectedIndex].Controls.Add(grid);

                ResetClass rst = new ResetClass(tables[TabMarks.SelectedIndex], grid);

                tables[TabMarks.SelectedIndex] = rst.Reset(type);
            }
        }