DataGridViewCheckBoxColumn.DefaultCellStyle Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает стиль по умолчанию для ячеек столбца.
public:
virtual property System::Windows::Forms::DataGridViewCellStyle ^ DefaultCellStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); void set(System::Windows::Forms::DataGridViewCellStyle ^ value); };
[System.ComponentModel.Browsable(true)]
public override System.Windows.Forms.DataGridViewCellStyle DefaultCellStyle { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.DefaultCellStyle : System.Windows.Forms.DataGridViewCellStyle with get, set
Public Overrides Property DefaultCellStyle As DataGridViewCellStyle
Значение свойства
Стиль DataGridViewCellStyle, который будет применен в качестве стиля по умолчанию.
- Атрибуты
Примеры
В следующем примере кода показано использование этого свойства.
private void ChangeColumnAlignment()
{
songsDataGridView.Columns["Title"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
songsDataGridView.Columns["Title"].Name = DataGridViewContentAlignment.BottomCenter.ToString();
songsDataGridView.Columns["Artist"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft;
songsDataGridView.Columns["Artist"].Name = DataGridViewContentAlignment.BottomLeft.ToString();
songsDataGridView.Columns["Album"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
songsDataGridView.Columns["Album"].Name = DataGridViewContentAlignment.BottomRight.ToString();
songsDataGridView.Columns["Release Date"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
songsDataGridView.Columns["Release Date"].Name = DataGridViewContentAlignment.MiddleCenter.ToString();
songsDataGridView.Columns["Track"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
songsDataGridView.Columns["Track"].Name = DataGridViewContentAlignment.MiddleLeft.ToString();
}
Private Sub ChangeColumnAlignment()
songsDataGridView.Columns("Title").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
songsDataGridView.Columns("Title").Name = DataGridViewContentAlignment.BottomCenter.ToString()
songsDataGridView.Columns("Artist").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft
songsDataGridView.Columns("Artist").Name = DataGridViewContentAlignment.BottomLeft.ToString()
songsDataGridView.Columns("Album").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight
songsDataGridView.Columns("Album").Name = DataGridViewContentAlignment.BottomRight.ToString()
songsDataGridView.Columns("Release Date").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
songsDataGridView.Columns("Release Date").Name = DataGridViewContentAlignment.MiddleCenter.ToString()
songsDataGridView.Columns("Track").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
songsDataGridView.Columns("Track").Name = DataGridViewContentAlignment.MiddleLeft.ToString()
End Sub
Комментарии
Значение по умолчанию DataGridViewCellStyle , возвращаемое этим свойством, имеет следующие начальные значения свойств:
СвойствоDataGridViewCellStyle |
Значение по умолчанию |
|---|---|
| Alignment | DataGridViewContentAlignment.MiddleCenter |
| NullValue | CheckState.Indeterminate , если начальное ThreeState значение свойства равно true; в противном случае false. |
Эти значения переопределяют значение, указанное в DefaultCellStyle свойстве DataGridView элемента управления, но может быть переопределено другими свойствами стиля ячейки. Дополнительные сведения см. в разделе "Стили ячеек" в элементе управления Windows Forms DataGridView.
NullValue Если свойство объекта, возвращаемого свойствомDefaultCellStyle, имеет значениеfalse, измените ThreeState значение свойства на true автоматическое IndeterminateзначениеNullValue. Если NullValue значение имеет значение Indeterminate, измените ThreeState значение свойства на false автоматически заданное NullValue falseзначение.