DataGridView.TopLeftHeaderCell 属性

定义

获取或设置位于 DataGridView 控件左上角的标题单元格。Gets or sets the header cell located in the upper left corner of the DataGridView control.

public:
 property System::Windows::Forms::DataGridViewHeaderCell ^ TopLeftHeaderCell { System::Windows::Forms::DataGridViewHeaderCell ^ get(); void set(System::Windows::Forms::DataGridViewHeaderCell ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridViewHeaderCell TopLeftHeaderCell { get; set; }
member this.TopLeftHeaderCell : System.Windows.Forms.DataGridViewHeaderCell with get, set
Public Property TopLeftHeaderCell As DataGridViewHeaderCell

属性值

位于 DataGridViewHeaderCell 左上角的 DataGridViewThe DataGridViewHeaderCell located at the upper left corner of the DataGridView.

属性

示例

下面的代码示例使用此属性在 DataGridView 控件的左上角显示一个值。The following code example uses this property to display a value in the upper-left corner of a DataGridView control. 此值在主/从方案中标记子表。This value labels a child table in a master/detail scenario. 此示例摘自 DataGridViewComboBoxColumn 类概述主题中提供的一个更大的示例。This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

private:
    void SetUpDataGridView2()
    {
        DataGridView2->Dock = DockStyle::Bottom;
        DataGridView2->TopLeftHeaderCell->Value = "Sales Details";
        DataGridView2->RowHeadersWidthSizeMode = 
            DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders;
    }
private void SetUpDataGridView2()
{
    DataGridView2.Dock = DockStyle.Bottom;
    DataGridView2.TopLeftHeaderCell.Value = "Sales Details";
    DataGridView2.RowHeadersWidthSizeMode = 
        DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
}
Private Sub SetUpDataGridView2()
    DataGridView2.Dock = DockStyle.Bottom
    DataGridView2.TopLeftHeaderCell.Value = "Sales Details"
    DataGridView2.RowHeadersWidthSizeMode = _
    DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders
End Sub

注解

通过设置此属性,可以设置单元格的值,将快捷菜单与它相关联,或执行可以在 @no__t 上执行的任何其他操作。Setting this property allows you to set a value for the cell, associate a shortcut menu with it, or perform any other operations you can perform on a DataGridViewHeaderCell.

在设计用于与从右到左的语言一起使用的应用程序中,此属性所表示的单元格通常位于右上角。In applications designed for use with right-to-left languages, the cell represented by this property is typically in the upper-right corner.

适用于

另请参阅