private void mnuCtxRowHeaderCols_Click(object sender, EventArgs e) { string[] astrCols; bool[] abSelected; int[] anColIdx; FormColPicker formColPicker; DataGridViewColumn dvgCol; int nColIdx; int nColCount = dataGrid.Columns.Count; astrCols = new string[nColCount]; abSelected = new bool[nColCount]; anColIdx = new int[nColCount]; for (int i = 0; i < nColCount; i++) { dvgCol = dataGrid.Columns[i]; nColIdx = dvgCol.DisplayIndex; astrCols[nColIdx] = (string)dvgCol.HeaderCell.Value; abSelected[nColIdx] = dvgCol.Visible; anColIdx[nColIdx] = i; } formColPicker = new FormColPicker(astrCols, abSelected, anColIdx); formColPicker.ApplyCols += formColPicker_Apply; formColPicker.ShowDialog(); }
public void formColPicker_Apply(FormColPicker formColPicker) { string [] astrCols; bool [] abVisible; int [] anColIdx; DataGridViewColumn dvgCol; nCntHiddenCols = 0; formColPicker.GetColumns(out astrCols, out abVisible, out anColIdx); for (int i = 0; i < anColIdx.GetLength(0); i++) { dvgCol = dataGrid.Columns[anColIdx[i]]; dvgCol.Visible = abVisible[i]; if (abVisible[i] == false) { nCntHiddenCols++; } formTemplate.UpdateCol(new FormGenericTableLayout.ColDefinition(dvgCol.Name, dvgCol.Width, dvgCol.Visible)); } UpdateHiddenColsText(); }