1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// Constructeur
public GridControl()
{
colInclude = new DataGridViewCheckBoxColumn(false);
colDate = new DataGridViewTextBoxColumn();
colHour = new DataGridViewTextBoxColumn();
colMX = new DataGridViewTextBoxColumn();
SetProperties();
}
public void SetProperties()
{
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this.AllowUserToResizeColumns = false;
this.AllowUserToResizeRows = false;
this.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.Dock = System.Windows.Forms.DockStyle.Fill;
this.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.Location = new System.Drawing.Point(0, 0);
this.Name = "NumValuesDataGrid";
this.ReadOnly = true;
this.RowHeadersVisible = false;
this.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.RowTemplate.ReadOnly = true;
this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.ShowCellErrors = false;
this.ShowCellToolTips = false;
this.ShowEditingIcon = false;
this.ShowRowErrors = false;
this.Size = new System.Drawing.Size(434, 118);
this.TabIndex = 0;
}
// Ensuite ajout des colonnes
public void SetHeaders()
{
this.Columns.Clear();
if (Condition1)
{
this.colInclude.Name = "colInclude";
this.colInclude.HeaderText = "Inclure";
this.colInclude.ReadOnly = true;
this.colInclude.MinimumWidth = 50;
this.colInclude.Width = 50;
this.colInclude.DisplayIndex = 0;
this.colDate.Name = "colDate";
this.colDate.HeaderText = "Date";
this.colDate.ReadOnly = true;
this.colDate.MinimumWidth = 100;
this.colDate.Width = 100;
this.colDate.DisplayIndex = 1;
this.colHour.Name = "colHour";
this.colHour.HeaderText = "Heure";
this.colHour.ReadOnly = true;
this.colHour.MinimumWidth = 50;
this.colHour.Width = 50;
this.colHour.DisplayIndex = 2;
base.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
colInclude,
colDate,
colHour,
});
}
else // Condition 2
{
this.colInclude.Name = "colInclude";
this.colInclude.HeaderText = "Inclure";
this.colInclude.ReadOnly = true;
this.colInclude.MinimumWidth = 50;
this.colInclude.Width = 50;
this.colInclude.DisplayIndex = 0;
this.colMW.Name = "colMW";
this.colMW.HeaderText = "MW";
this.colMW.ReadOnly = true;
this.colMW.MinimumWidth = 50;
this.colMW.Width = 77;
this.colMW.DisplayIndex = 3;
base.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
colInclude,
colMW});
}
} |
Partager