private void setupPage() { // Back out if the page has already been SetUp if (currentDgv != null) { ((DataGridView)mainTabControl.SelectedTab.Controls[0]).SelectionMode = DataGridViewSelectionMode.RowHeaderSelect; return; } CtfEditorGamePage page; // Setup Page if (mainTabControl.SelectedIndex == (int)CtfEditorMainTabs.Formula1) { page = new CtfEditorGamePage(File.Open(System.Windows.Forms.Application.StartupPath + "\\ctfSchemaF12012.xml", FileMode.Open), CtfEditorMainTabs.Formula1); } else if (mainTabControl.SelectedIndex == (int)CtfEditorMainTabs.Dirt) { page = new CtfEditorGamePage(File.Open(System.Windows.Forms.Application.StartupPath + "\\ctfSchemaDirt.xml", FileMode.Open), CtfEditorMainTabs.Dirt); } else if (mainTabControl.SelectedIndex == (int)CtfEditorMainTabs.Other) { page = new CtfEditorGamePage(File.Open(System.Windows.Forms.Application.StartupPath + "\\ctfSchemaGrid2.xml", FileMode.Open), CtfEditorMainTabs.Other); } else if (mainTabControl.SelectedIndex == (int)CtfEditorMainTabs.Grid) { page = new CtfEditorGamePage(File.Open(System.Windows.Forms.Application.StartupPath + "\\ctfSchemaGrid.xml", FileMode.Open), CtfEditorMainTabs.Grid); } else { // SHOULD NOT HAPPEN, just doing it to satisfy compiler return; } // Setup DGV DataGridView dgv; dgv = new DataGridView(); dgv.Dock = DockStyle.Fill; //dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; //dgv.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; dgv.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; //dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dgv.DefaultCellStyle.WrapMode = DataGridViewTriState.True; dgv.AllowUserToAddRows = false; dgv.AllowUserToDeleteRows = false; dgv.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#E8EDFF"); dgv.TopLeftHeaderCell.Value = "ID"; dgv.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect; dgv.CellValueChanged += new DataGridViewCellEventHandler(dgv_CellValueChanged); dgv.CellBeginEdit += new DataGridViewCellCancelEventHandler(dgv_CellBeginEdit); dgv.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(dgv_ColumnHeaderMouseClick); dgv.CellMouseDown += new DataGridViewCellMouseEventHandler(dgv_CellMouseDown); dgv.DataError += new DataGridViewDataErrorEventHandler(dgv_DataError); dgv.CellEnter += new DataGridViewCellEventHandler(dgv_CellEnter); dgv.KeyDown += new KeyEventHandler(dgv_KeyDown); dgv.ColumnHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(dgv_ColumnHeaderMouseDoubleClick); // Load Page Contents mainTabControl.SelectedTab.Tag = page; dgv.Columns.Add("entryName", "Entry Name"); dgv.Columns[0].MinimumWidth = 150; dgv.Columns[0].ValueType = typeof(string); dgv.Columns[0].ReadOnly = true; dgv.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; DGVColumnFilterContextControl colFilter = new DGVColumnFilterContextControl(dgv, 0); dgv.SuspendDrawing(); foreach (CtfEntryInfo entryInfo in page.ctfEntryInfo) { dgv.Rows.Add(entryInfo.name); dgv.Rows[entryInfo.id].HeaderCell.Value = Convert.ToString(entryInfo.id); //entryInfo.id == 0 || entryInfo.id == 1 || entryInfo.refID >= 0 || if (entryInfo.readOnly) { dgv.Rows[entryInfo.id].ReadOnly = true; } } dgv.ResumeDrawing(); mainTabControl.SelectedTab.Controls.Add(dgv); ActiveControl = currentDgv; }