DataGridViewLinkColumn.CellTemplate Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает или задает шаблон, используемый для создания новых ячеек.
public:
virtual property System::Windows::Forms::DataGridViewCell ^ CellTemplate { System::Windows::Forms::DataGridViewCell ^ get(); void set(System::Windows::Forms::DataGridViewCell ^ value); };
[System.ComponentModel.Browsable(false)]
public override System.Windows.Forms.DataGridViewCell CellTemplate { get; set; }
[System.ComponentModel.Browsable(false)]
public override System.Windows.Forms.DataGridViewCell? CellTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CellTemplate : System.Windows.Forms.DataGridViewCell with get, set
Public Overrides Property CellTemplate As DataGridViewCell
Значение свойства
А DataGridViewCell все остальные ячейки в столбце моделиируются после. Значением по умолчанию является новый DataGridViewLinkCell экземпляр.
- Атрибуты
Исключения
При задании этого свойства значение, которое не является типом DataGridViewLinkCell.
Примеры
В следующем примере кода показано, как использовать DataGridViewCell его в качестве шаблона.DataGridViewColumn Изменения стиля, внесенные в любую ячейку в столбце, влияют на все ячейки столбца. Этот пример кода является частью более крупного примера, предоставленного для DataGridViewColumn класса.
void CustomizeCellsInThirdColumn()
{
int thirdColumn = 2;
DataGridViewColumn^ column = dataGridView->Columns[ thirdColumn ];
DataGridViewCell^ cell = gcnew DataGridViewTextBoxCell;
cell->Style->BackColor = Color::Wheat;
column->CellTemplate = cell;
}
private void CustomizeCellsInThirdColumn()
{
int thirdColumn = 2;
DataGridViewColumn column =
dataGridView.Columns[thirdColumn];
DataGridViewCell cell = new DataGridViewTextBoxCell();
cell.Style.BackColor = Color.Wheat;
column.CellTemplate = cell;
}
Private Sub CustomizeCellsInThirdColumn()
Dim thirdColumn As Integer = 2
Dim column As DataGridViewColumn = _
dataGridView.Columns(thirdColumn)
Dim cell As DataGridViewCell = _
New DataGridViewTextBoxCell()
cell.Style.BackColor = Color.Wheat
column.CellTemplate = cell
End Sub
Комментарии
Конструктор класса DataGridViewLinkColumn инициализирует это свойство в только что созданное.DataGridViewLinkCell
Предостережение
Изменение свойств шаблона ячейки не повлияет на пользовательский интерфейс существующих ячеек столбца. Эти изменения очевидны только после повторного создания столбца (например, путем сортировки столбца или вызова DataGridView.InvalidateColumn метода).