DataGridView 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在可自定义的网格中显示数据。
public ref class DataGridView : System::Windows::Forms::Control, System::ComponentModel::ISupportInitialize
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.Ask)]
public class DataGridView : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize
[System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")]
[System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.Ask)]
public class DataGridView : System.Windows.Forms.Control, System.ComponentModel.ISupportInitialize
[<System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")>]
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.Ask)>]
type DataGridView = class
inherit Control
interface ISupportInitialize
[<System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")>]
[<System.Windows.Forms.Docking(System.Windows.Forms.DockingBehavior.Ask)>]
type DataGridView = class
inherit Control
interface ISupportInitialize
Public Class DataGridView
Inherits Control
Implements ISupportInitialize
- 继承
- 属性
- 实现
示例
下面的代码示例演示如何初始化未绑定 DataGridView 控件。
using System;
using System.Drawing;
using System.Windows.Forms;
public class Form1 : System.Windows.Forms.Form
{
private Panel buttonPanel = new Panel();
private DataGridView songsDataGridView = new DataGridView();
private Button addNewRowButton = new Button();
private Button deleteRowButton = new Button();
public Form1()
{
this.Load += new EventHandler(Form1_Load);
}
private void Form1_Load(System.Object sender, System.EventArgs e)
{
SetupLayout();
SetupDataGridView();
PopulateDataGridView();
}
private void songsDataGridView_CellFormatting(object sender,
System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
if (e != null)
{
if (this.songsDataGridView.Columns[e.ColumnIndex].Name == "Release Date")
{
if (e.Value != null)
{
try
{
e.Value = DateTime.Parse(e.Value.ToString())
.ToLongDateString();
e.FormattingApplied = true;
}
catch (FormatException)
{
Console.WriteLine("{0} is not a valid date.", e.Value.ToString());
}
}
}
}
}
private void addNewRowButton_Click(object sender, EventArgs e)
{
this.songsDataGridView.Rows.Add();
}
private void deleteRowButton_Click(object sender, EventArgs e)
{
if (this.songsDataGridView.SelectedRows.Count > 0 &&
this.songsDataGridView.SelectedRows[0].Index !=
this.songsDataGridView.Rows.Count - 1)
{
this.songsDataGridView.Rows.RemoveAt(
this.songsDataGridView.SelectedRows[0].Index);
}
}
private void SetupLayout()
{
this.Size = new Size(600, 500);
addNewRowButton.Text = "Add Row";
addNewRowButton.Location = new Point(10, 10);
addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
deleteRowButton.Text = "Delete Row";
deleteRowButton.Location = new Point(100, 10);
deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
buttonPanel.Controls.Add(addNewRowButton);
buttonPanel.Controls.Add(deleteRowButton);
buttonPanel.Height = 50;
buttonPanel.Dock = DockStyle.Bottom;
this.Controls.Add(this.buttonPanel);
}
private void SetupDataGridView()
{
this.Controls.Add(songsDataGridView);
songsDataGridView.ColumnCount = 5;
songsDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy;
songsDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
songsDataGridView.ColumnHeadersDefaultCellStyle.Font =
new Font(songsDataGridView.Font, FontStyle.Bold);
songsDataGridView.Name = "songsDataGridView";
songsDataGridView.Location = new Point(8, 8);
songsDataGridView.Size = new Size(500, 250);
songsDataGridView.AutoSizeRowsMode =
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
songsDataGridView.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Single;
songsDataGridView.CellBorderStyle = DataGridViewCellBorderStyle.Single;
songsDataGridView.GridColor = Color.Black;
songsDataGridView.RowHeadersVisible = false;
songsDataGridView.Columns[0].Name = "Release Date";
songsDataGridView.Columns[1].Name = "Track";
songsDataGridView.Columns[2].Name = "Title";
songsDataGridView.Columns[3].Name = "Artist";
songsDataGridView.Columns[4].Name = "Album";
songsDataGridView.Columns[4].DefaultCellStyle.Font =
new Font(songsDataGridView.DefaultCellStyle.Font, FontStyle.Italic);
songsDataGridView.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
songsDataGridView.MultiSelect = false;
songsDataGridView.Dock = DockStyle.Fill;
songsDataGridView.CellFormatting += new
DataGridViewCellFormattingEventHandler(
songsDataGridView_CellFormatting);
}
private void PopulateDataGridView()
{
string[] row0 = { "11/22/1968", "29", "Revolution 9",
"Beatles", "The Beatles [White Album]" };
string[] row1 = { "1960", "6", "Fools Rush In",
"Frank Sinatra", "Nice 'N' Easy" };
string[] row2 = { "11/11/1971", "1", "One of These Days",
"Pink Floyd", "Meddle" };
string[] row3 = { "1988", "7", "Where Is My Mind?",
"Pixies", "Surfer Rosa" };
string[] row4 = { "5/1981", "9", "Can't Find My Mind",
"Cramps", "Psychedelic Jungle" };
string[] row5 = { "6/10/2003", "13",
"Scatterbrain. (As Dead As Leaves.)",
"Radiohead", "Hail to the Thief" };
string[] row6 = { "6/30/1992", "3", "Dress", "P J Harvey", "Dry" };
songsDataGridView.Rows.Add(row0);
songsDataGridView.Rows.Add(row1);
songsDataGridView.Rows.Add(row2);
songsDataGridView.Rows.Add(row3);
songsDataGridView.Rows.Add(row4);
songsDataGridView.Rows.Add(row5);
songsDataGridView.Rows.Add(row6);
songsDataGridView.Columns[0].DisplayIndex = 3;
songsDataGridView.Columns[1].DisplayIndex = 4;
songsDataGridView.Columns[2].DisplayIndex = 0;
songsDataGridView.Columns[3].DisplayIndex = 1;
songsDataGridView.Columns[4].DisplayIndex = 2;
}
[STAThreadAttribute()]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
Imports System.Drawing
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
Private buttonPanel As New Panel
Private WithEvents songsDataGridView As New DataGridView
Private WithEvents addNewRowButton As New Button
Private WithEvents deleteRowButton As New Button
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
SetupLayout()
SetupDataGridView()
PopulateDataGridView()
End Sub
Private Sub songsDataGridView_CellFormatting(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles songsDataGridView.CellFormatting
If e IsNot Nothing Then
If Me.songsDataGridView.Columns(e.ColumnIndex).Name = _
"Release Date" Then
If e.Value IsNot Nothing Then
Try
e.Value = DateTime.Parse(e.Value.ToString()) _
.ToLongDateString()
e.FormattingApplied = True
Catch ex As FormatException
Console.WriteLine("{0} is not a valid date.", e.Value.ToString())
End Try
End If
End If
End If
End Sub
Private Sub addNewRowButton_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles addNewRowButton.Click
Me.songsDataGridView.Rows.Add()
End Sub
Private Sub deleteRowButton_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles deleteRowButton.Click
If Me.songsDataGridView.SelectedRows.Count > 0 AndAlso _
Not Me.songsDataGridView.SelectedRows(0).Index = _
Me.songsDataGridView.Rows.Count - 1 Then
Me.songsDataGridView.Rows.RemoveAt( _
Me.songsDataGridView.SelectedRows(0).Index)
End If
End Sub
Private Sub SetupLayout()
Me.Size = New Size(600, 500)
With addNewRowButton
.Text = "Add Row"
.Location = New Point(10, 10)
End With
With deleteRowButton
.Text = "Delete Row"
.Location = New Point(100, 10)
End With
With buttonPanel
.Controls.Add(addNewRowButton)
.Controls.Add(deleteRowButton)
.Height = 50
.Dock = DockStyle.Bottom
End With
Me.Controls.Add(Me.buttonPanel)
End Sub
Private Sub SetupDataGridView()
Me.Controls.Add(songsDataGridView)
songsDataGridView.ColumnCount = 5
With songsDataGridView.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(songsDataGridView.Font, FontStyle.Bold)
End With
With songsDataGridView
.Name = "songsDataGridView"
.Location = New Point(8, 8)
.Size = New Size(500, 250)
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single
.CellBorderStyle = DataGridViewCellBorderStyle.Single
.GridColor = Color.Black
.RowHeadersVisible = False
.Columns(0).Name = "Release Date"
.Columns(1).Name = "Track"
.Columns(2).Name = "Title"
.Columns(3).Name = "Artist"
.Columns(4).Name = "Album"
.Columns(4).DefaultCellStyle.Font = _
New Font(Me.songsDataGridView.DefaultCellStyle.Font, FontStyle.Italic)
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.MultiSelect = False
.Dock = DockStyle.Fill
End With
End Sub
Private Sub PopulateDataGridView()
Dim row0 As String() = {"11/22/1968", "29", "Revolution 9", _
"Beatles", "The Beatles [White Album]"}
Dim row1 As String() = {"1960", "6", "Fools Rush In", _
"Frank Sinatra", "Nice 'N' Easy"}
Dim row2 As String() = {"11/11/1971", "1", "One of These Days", _
"Pink Floyd", "Meddle"}
Dim row3 As String() = {"1988", "7", "Where Is My Mind?", _
"Pixies", "Surfer Rosa"}
Dim row4 As String() = {"5/1981", "9", "Can't Find My Mind", _
"Cramps", "Psychedelic Jungle"}
Dim row5 As String() = {"6/10/2003", "13", _
"Scatterbrain. (As Dead As Leaves.)", _
"Radiohead", "Hail to the Thief"}
Dim row6 As String() = {"6/30/1992", "3", "Dress", "P J Harvey", "Dry"}
With Me.songsDataGridView.Rows
.Add(row0)
.Add(row1)
.Add(row2)
.Add(row3)
.Add(row4)
.Add(row5)
.Add(row6)
End With
With Me.songsDataGridView
.Columns(0).DisplayIndex = 3
.Columns(1).DisplayIndex = 4
.Columns(2).DisplayIndex = 0
.Columns(3).DisplayIndex = 1
.Columns(4).DisplayIndex = 2
End With
End Sub
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
End Class
注解
该 DataGridView 控件提供用于显示数据的可自定义表。 类DataGridView允许通过使用 、、 和 等DefaultCellStyleColumnHeadersDefaultCellStyle属性自定义单元格、行、CellBorderStyle列和GridColor边框。 有关详细信息,请参阅 Windows 窗体 DataGridView 控件中的基本格式设置和样式设置。
可以使用 控件 DataGridView 来显示包含或不带基础数据源的数据。 如果不指定数据源,则可以创建包含数据的列和行,并使用 Rows 和 Columns 属性将其直接添加到 。DataGridView 还可以使用 Rows 集合访问 DataGridViewRow 对象和 DataGridViewRow.Cells 属性来直接读取或写入单元格值。 索引 Item[] 器还提供对单元格的直接访问。
作为手动填充控件的替代方法,可以设置 DataSource 和 DataMember 属性以将 绑定到 DataGridView 数据源,并使用数据自动填充它。 有关详细信息,请参阅在 Windows 窗体 DataGridView 控件中显示数据。
处理大量数据时,可以将 属性true
设置为 VirtualMode 以显示可用数据的子集。 虚拟模式需要实现从中 DataGridView 填充控件的数据缓存。 有关详细信息,请参阅 Windows 窗体 DataGridView 控件中的数据显示模式。
有关控件中 DataGridView 可用功能的其他信息,请参阅 DataGridView 控件。 下表提供了指向常见任务的直接链接。
控件 DataGridView 替换并扩展控件 DataGrid 。 有关详细信息,请参阅 Windows 窗体 DataGridView 和 DataGrid 控件之间的差异。
注意
控件DataGridView从 ContextMenuControl继承 和 ContextMenuStrip 属性,ContextMenuStrip但仅支持 属性。 将 ContextMenu 属性与 控件一起使用 DataGridView 不起作用。
构造函数
DataGridView() |
初始化 DataGridView 类的新实例。 |
属性
AccessibilityObject |
获取分配给该控件的 AccessibleObject。 (继承自 Control) |
AccessibleDefaultActionDescription |
获取或设置控件的默认操作说明以供具有辅助功能的客户端应用程序使用。 (继承自 Control) |
AccessibleDescription |
获取或设置辅助功能客户端应用程序使用的控件说明。 (继承自 Control) |
AccessibleName |
获取或设置辅助功能客户端应用程序所使用的控件名称。 (继承自 Control) |
AccessibleRole |
获取或设置控件的辅助性角色。 (继承自 Control) |
AdjustedTopLeftHeaderBorderStyle |
获取 DataGridView 左上角单元格的边框样式。 |
AdvancedCellBorderStyle |
获取 DataGridView 中单元格的边框样式。 |
AdvancedColumnHeadersBorderStyle |
获取 DataGridView 中列标题单元格的边框样式。 |
AdvancedRowHeadersBorderStyle |
获取 DataGridView 中行标题单元格的边框样式。 |
AllowDrop |
获取或设置一个值,该值指示控件是否可以接受用户拖放到它上面的数据。 (继承自 Control) |
AllowUserToAddRows |
获取或设置一个值,该值指示是否向用户显示添加行的选项。 |
AllowUserToDeleteRows |
获取或设置一个值,该值指示是否允许用户从 DataGridView 中删除行。 |
AllowUserToOrderColumns |
获取或设置一个值,该值指示是否允许通过手动对列重新定位。 |
AllowUserToResizeColumns |
获取或设置一个值,该值指示用户是否可以调整列的大小。 |
AllowUserToResizeRows |
获取或设置一个值,该值指示用户是否可以调整行的大小。 |
AlternatingRowsDefaultCellStyle |
获取或设置应用于 DataGridView 的奇数行的默认单元格样式。 |
Anchor |
获取或设置控件绑定到的容器的边缘并确定控件如何随其父级一起调整大小。 (继承自 Control) |
AutoGenerateColumns |
获取或设置一个值,该值指示在设置 DataSource 或 DataMember 属性时是否自动创建列。 |
AutoScrollOffset |
获取或设置一个值,该值指示在 ScrollControlIntoView(Control) 中将控件滚动到何处。 (继承自 Control) |
AutoSize |
此属性与此类无关。 |
AutoSizeColumnsMode |
获取或设置一个值,该值指示如何确定列宽。 |
AutoSizeRowsMode |
获取或设置一个值,该值指示如何确定行高。 |
BackColor |
获取或设置控件的背景色。 |
BackgroundColor |
获取或设置 DataGridView 的背景色。 |
BackgroundImage |
获取或设置在控件中显示的背景图像。 |
BackgroundImageLayout |
获取或设置在 ImageLayout 枚举中定义的背景图像布局。 |
BindingContext |
获取或设置控件的 BindingContext。 (继承自 Control) |
BorderStyle |
获取或设置 DataGridView 的边框样式。 |
Bottom |
获取控件下边缘与其容器的工作区上边缘之间的距离(以像素为单位)。 (继承自 Control) |
Bounds |
获取或设置控件(包括其非工作区元素)相对于其父控件的大小和位置(以像素为单位)。 (继承自 Control) |
CanEnableIme |
获取一个用以指示是否可以将 ImeMode 属性设置为活动值的值,以启用 IME 支持。 |
CanFocus |
获取一个值,该值指示控件是否可以接收焦点。 (继承自 Control) |
CanRaiseEvents |
确定是否可以在控件上引发事件。 (继承自 Control) |
CanSelect |
获取一个值,该值指示是否可以选中控件。 (继承自 Control) |
Capture |
获取或设置一个值,该值指示控件是否已捕获鼠标。 (继承自 Control) |
CausesValidation |
获取或设置一个值,该值指示控件是否会引起在任何需要在接收焦点时执行验证的控件上执行验证。 (继承自 Control) |
CellBorderStyle |
获取 DataGridView 的单元格边框样式。 |
ClientRectangle |
获取表示控件的工作区的矩形。 (继承自 Control) |
ClientSize |
获取或设置控件的工作区的高度和宽度。 (继承自 Control) |
ClipboardCopyMode |
获取或设置一个值,该值指示用户是否可以将单元格的文本值复制到 Clipboard,以及是否包括行标题和列标题文本。 |
ColumnCount |
获取或设置 DataGridView 中显示的列数。 |
ColumnHeadersBorderStyle |
获取应用于列标题的边框样式。 |
ColumnHeadersDefaultCellStyle |
获取或设置默认列标题样式。 |
ColumnHeadersHeight |
获取或设置列标题行的高度(以像素为单位)。 |
ColumnHeadersHeightSizeMode |
获取或设置一个值,该值指示是否可以调整列标题的高度,以及它是由用户调整还是根据标题的内容自动调整。 |
ColumnHeadersVisible |
获取或设置一个值,该值指示是否显示列标题行。 |
Columns |
获取一个集合,它包含控件中的所有列。 |
CompanyName |
获取包含控件的应用程序的公司名称或创建者。 (继承自 Control) |
Container |
获取包含 IContainer 的 Component。 (继承自 Component) |
ContainsFocus |
获取一个值,该值指示控件或它的一个子控件当前是否有输入焦点。 (继承自 Control) |
ContextMenu |
获取或设置与控件关联的快捷菜单。 (继承自 Control) |
ContextMenuStrip |
获取或设置与此控件关联的 ContextMenuStrip。 (继承自 Control) |
Controls |
获取包含在控件内的控件的集合。 (继承自 Control) |
Created |
获取一个值,该值指示控件是否已经创建。 (继承自 Control) |
CreateParams |
获取创建控件句柄时所需要的创建参数。 (继承自 Control) |
CurrentCell |
获取或设置当前处于活动状态的单元格。 |
CurrentCellAddress |
获取当前处于活动状态的单元格的行索引和列索引。 |
CurrentRow |
获取包含当前单元格的行。 |
Cursor |
获取或设置当鼠标指针位于控件上时显示的光标。 (继承自 Control) |
DataBindings |
为该控件获取数据绑定。 (继承自 Control) |
DataContext |
获取或设置用于数据绑定的数据上下文。 这是一个环境属性。 (继承自 Control) |
DataMember |
获取或设置 DataGridView 正在为其显示数据的数据源中的列表或表的名称。 |
DataSource |
获取或设置 DataGridView 所显示数据的数据源。 |
DefaultCellStyle |
在未设置其他单元格样式属性的情况下,获取或设置应用于 DataGridView 中的单元格的默认单元格样式。 |
DefaultCursor |
获取或设置控件的默认光标。 (继承自 Control) |
DefaultImeMode |
获取控件支持的默认输入法编辑器 (IME) 模式。 (继承自 Control) |
DefaultMargin |
获取控件之间默认指定的间距(以像素为单位)。 (继承自 Control) |
DefaultMaximumSize |
获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最大大小。 (继承自 Control) |
DefaultMinimumSize |
获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最小大小。 (继承自 Control) |
DefaultPadding |
获取控件内容的内部间距(以像素为单位)。 (继承自 Control) |
DefaultSize |
获取控件的默认初始大小。 |
DesignMode |
获取一个值,用以指示 Component 当前是否处于设计模式。 (继承自 Component) |
DeviceDpi |
获取显示当前控件的显示设备的 DPI 值。 (继承自 Control) |
DisplayRectangle |
获取表示控件的显示区域的矩形。 |
Disposing |
获取一个值,该值指示 Control 基类是否在释放进程中。 (继承自 Control) |
Dock |
获取或设置哪些控件边框停靠到其父控件并确定控件如何随其父级一起调整大小。 (继承自 Control) |
DoubleBuffered |
获取或设置一个值,该值指示此控件是否应使用辅助缓冲区重绘其图面,以减少或避免闪烁。 (继承自 Control) |
EditingControl |
获取当前单元格承载的控件(如果包含编辑控件的单元格处于编辑模式下)。 |
EditingPanel |
获取包含 EditingControl 的面板。 |
EditMode |
获取或设置一个值,该值指示如何开始编辑单元格。 |
Enabled |
获取或设置一个值,该值指示控件是否可以对用户交互作出响应。 (继承自 Control) |
EnableHeadersVisualStyles |
获取或设置一个值,该值指示在对应用程序启用了可视样式的情况下,行标题和列标题是否使用用户当前主题的可视样式。 |
Events |
获取附加到此 Component 的事件处理程序的列表。 (继承自 Component) |
FirstDisplayedCell |
获取或设置当前显示在 DataGridView 中的第一个单元格;此单元格通常位于左上角。 |
FirstDisplayedScrollingColumnHiddenWidth |
获取该列中当前不在视图区域内的部分的宽度。 |
FirstDisplayedScrollingColumnIndex |
获取或设置某一列的索引,该列是显示在 DataGridView 上的第一列。 |
FirstDisplayedScrollingRowIndex |
获取或设置某一行的索引,该行是显示在 DataGridView 上的第一行。 |
Focused |
获取一个值,该值指示控件是否有输入焦点。 (继承自 Control) |
Font |
获取或设置 DataGridView 显示的文本的字体。 |
FontHeight |
获取或设置控件的字体的高度。 (继承自 Control) |
ForeColor |
获取或设置 DataGridView 的前景色。 |
GridColor |
获取和设置网格线的颜色,网格线对 DataGridView 的单元格进行分隔。 |
Handle |
获取控件绑定到的窗口句柄。 (继承自 Control) |
HasChildren |
获取一个值,该值指示控件是否包含一个或多个子控件。 (继承自 Control) |
Height |
获取或设置控件的高度。 (继承自 Control) |
HorizontalScrollBar |
获取控件的水平滚动条。 |
HorizontalScrollingOffset |
获取或设置控件水平滚动的像素数。 |
ImeMode |
获取或设置控件的输入法编辑器 (IME) 模式。 (继承自 Control) |
ImeModeBase |
获取或设置控件的 IME 模式。 (继承自 Control) |
InvokeRequired |
获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用 Invoke 方法,因为调用方位于创建控件所在的线程以外的线程中。 (继承自 Control) |
IsAccessible |
获取或设置一个值,该值指示控件对辅助功能应用程序是否可见。 (继承自 Control) |
IsAncestorSiteInDesignMode |
指示此控件的上级之一是否位于 DesignMode 中。 此属性为只读。 (继承自 Control) |
IsCurrentCellDirty |
获取一个值,该值指示当前单元格是否有未提交的更改。 |
IsCurrentCellInEditMode |
获取一个值,该值指示是否正在编辑当前处于活动状态的单元格。 |
IsCurrentRowDirty |
获取一个值,该值指示当前行是否有未提交的更改。 |
IsDisposed |
获取一个值,该值指示控件是否已经被释放。 (继承自 Control) |
IsHandleCreated |
获取一个值,该值指示控件是否有与它关联的句柄。 (继承自 Control) |
IsMirrored |
获取一个值,该值指示此控件是否为镜像控件。 (继承自 Control) |
Item[Int32, Int32] |
提供索引器以获取或设置位于具有指定索引的列和行的交叉点处的单元格。 |
Item[String, Int32] |
提供索引器以获取或设置位于具有指定索引的行和具有指定名称的列的交叉点处的单元格。 |
LayoutEngine |
获取控件的布局引擎的缓存实例。 (继承自 Control) |
Left |
获取或设置控件左边缘与其容器的工作区左边缘之间的距离(以像素为单位)。 (继承自 Control) |
Location |
获取或设置该控件的左上角相对于其容器的左上角的坐标。 (继承自 Control) |
Margin |
获取或设置控件之间的空间。 (继承自 Control) |
MaximumSize |
获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的上限。 (继承自 Control) |
MinimumSize |
获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的下限。 (继承自 Control) |
MultiSelect |
获取或设置一个值,该值指示是否允许用户一次选择 DataGridView 的多个单元格、行或列。 |
Name |
获取或设置控件的名称。 (继承自 Control) |
NewRowIndex |
获取新记录所在行的索引。 |
Padding |
此属性与此控件无关。 |
Parent |
获取或设置控件的父容器。 (继承自 Control) |
PreferredSize |
获取可以容纳控件的矩形区域的大小。 (继承自 Control) |
ProductName |
获取包含控件的程序集的产品名称。 (继承自 Control) |
ProductVersion |
获取包含控件的程序集的版本。 (继承自 Control) |
ReadOnly |
获取或设置一个值,该值指示用户是否可以编辑 DataGridView 控件的单元格。 |
RecreatingHandle |
获取一个值,该值指示控件当前是否在重新创建其句柄。 (继承自 Control) |
Region |
获取或设置与控件关联的窗口区域。 (继承自 Control) |
RenderRightToLeft |
已过时。
已过时。
此属性现已过时。 (继承自 Control) |
ResizeRedraw |
获取或设置一个值,该值指示控件在调整大小时是否重绘自己。 (继承自 Control) |
Right |
获取控件右边缘与其容器的工作区左边缘之间的距离(以像素为单位)。 (继承自 Control) |
RightToLeft |
获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。 (继承自 Control) |
RowCount |
获取或设置 DataGridView 中显示的行数。 |
RowHeadersBorderStyle |
获取或设置行标题单元格的边框样式。 |
RowHeadersDefaultCellStyle |
获取或设置应用于行标题单元格的默认样式。 |
RowHeadersVisible |
获取或设置一个值,该值指示是否显示包含行标题的列。 |
RowHeadersWidth |
获取或设置包含行标题的列的宽度(以像素为单位)。 |
RowHeadersWidthSizeMode |
获取或设置一个值,该值指示是否可以调整行标题的宽度,以及它是由用户调整还是根据标题的内容自动调整。 |
Rows |
获取一个集合,该集合包含 DataGridView 控件中的所有行。 |
RowsDefaultCellStyle |
获取或设置应用于 DataGridView 的行单元格的默认样式。 |
RowTemplate |
获取或设置一行,该行表示控件中所有行的模板。 |
ScaleChildren |
获取一个值,该值确定子控件的缩放。 (继承自 Control) |
ScrollBars |
获取或设置要在 DataGridView 控件中显示的滚动条的类型。 |
SelectedCells |
获取用户选定的单元格的集合。 |
SelectedColumns |
获取用户选定的列的集合。 |
SelectedRows |
获取用户选定的行的集合。 |
SelectionMode |
获取或设置一个值,该值指示如何选择 DataGridView 的单元格。 |
ShowCellErrors |
获取或设置一个值,该值指示是否显示单元格错误。 |
ShowCellToolTips |
获取或设置一个值,该值指示当鼠标指针停留在单元格上或用户通过键盘导航到该单元格上时,是否显示工具提示。 |
ShowEditingIcon |
获取或设置一个值,该值指示编辑标志符号是否在所编辑的单元格的行标题中可见。 |
ShowFocusCues |
获取一个值,该值指示控件是否应显示聚焦框。 (继承自 Control) |
ShowKeyboardCues |
获取一个值,该值指示用户界面是否处于适当的状态以显示或隐藏键盘快捷键。 (继承自 Control) |
ShowRowErrors |
获取或设置一个值,该值指示行标题是否为包含数据输入错误的每一行显示错误标志符号。 |
Site |
获取或设置控件的站点。 (继承自 Control) |
Size |
获取或设置控件的高度和宽度。 (继承自 Control) |
SortedColumn |
获取 DataGridView 内容的当前排序所依据的列。 |
SortOrder |
获取一个值,该值指示是按升序或降序对 DataGridView 控件中的项进行排序,还是不排序。 |
StandardTab |
获取或设置一个值,该值指示按 Tab 键是否会将焦点按 Tab 键顺序移到下一个控件,而不是将焦点移到控件中的下一个单元格。 |
TabIndex |
获取或设置控件在其容器内的 Tab 键顺序。 (继承自 Control) |
TabStop |
获取或设置一个值,该值指示用户能否使用 Tab 键将焦点放到该控件上。 (继承自 Control) |
Tag |
获取或设置包含有关控件的数据的对象。 (继承自 Control) |
Text |
获取或设置与控件关联的文本。 |
Top |
获取或设置控件上边缘与其容器的工作区上边缘之间的距离(以像素为单位)。 (继承自 Control) |
TopLeftHeaderCell |
获取或设置位于 DataGridView 控件左上角的标题单元格。 |
TopLevelControl |
获取没有另一个 Windows 窗体控件作为其父级的父控件。 通常,这是控件所在的最外面的 Form。 (继承自 Control) |
UserSetCursor |
获取 Cursor 属性的默认值或用户指定值。 |
UseWaitCursor |
获取或设置一个值,该值指示是否将等待光标用于当前控件以及所有子控件。 (继承自 Control) |
VerticalScrollBar |
获取控件的垂直滚动条。 |
VerticalScrollingOffset |
获取控件垂直滚动的像素数。 |
VirtualMode |
获取或设置一个值,该值指示你是否为 DataGridView 控件提供了自己的数据管理操作。 |
Visible |
获取或设置一个值,该值指示是否显示该控件及其所有子控件。 (继承自 Control) |
Width |
获取或设置控件的宽度。 (继承自 Control) |
WindowTarget |
此属性与此类无关。 (继承自 Control) |
方法
事件
显式接口实现
IDropTarget.OnDragDrop(DragEventArgs) |
引发 DragDrop 事件。 (继承自 Control) |
IDropTarget.OnDragEnter(DragEventArgs) |
引发 DragEnter 事件。 (继承自 Control) |
IDropTarget.OnDragLeave(EventArgs) |
引发 DragLeave 事件。 (继承自 Control) |
IDropTarget.OnDragOver(DragEventArgs) |
引发 DragOver 事件。 (继承自 Control) |
ISupportInitialize.BeginInit() |
有关此成员的说明,请参见 BeginInit()。 |
ISupportInitialize.EndInit() |
有关此成员的说明,请参见 EndInit()。 |