private void DataGridView1_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (!LoginForm.Login) { return; } var cellRectangle = DataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); TABLECOLUMN tableCol = tableColList[e.ColumnIndex]; DataGridView1.Columns[e.ColumnIndex].HeaderCell.Style.BackColor = Color.FromArgb(72, 180, 225); int locationX = this.Location.X + DataGridView1.Location.X + cellRectangle.Location.X + 5; int locationY = this.Location.Y + DataGridView1.Location.Y + cellRectangle.Location.Y + cellRectangle.Height + 30; ColumnForm form = new ColumnForm(e.ColumnIndex, locationX, locationY, tableCol); if (form.ShowDialog(this) == DialogResult.OK) { tableCol.Name = form.ReturnName; tableCol.Formula = form.ReturnFormula; tableCol.Min = form.ReturnMin; tableCol.Max = form.ReturnMax; tableCol.Readvalue = form.ReturnReadvalue; tableColList[e.ColumnIndex] = tableCol; TableXml.SaveColumnInfo(stationComboBox.Text, modelComboBox.Text, customerComboBox.Text, e.ColumnIndex, tableCol); DataGridView1.Columns[e.ColumnIndex].Name = tableCol.Name; if (tableCol.Readvalue == 4) { DataGridView1.Columns[e.ColumnIndex].Width = 100; } else { DataGridView1.Columns[e.ColumnIndex].Width = 60; } } DataGridView1.Columns[e.ColumnIndex].HeaderCell.Style.BackColor = SystemColors.Control; }