DataGridViewCellPaintingEventArgs.State 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取当前 DataGridViewCell 的状态。
public:
property System::Windows::Forms::DataGridViewElementStates State { System::Windows::Forms::DataGridViewElementStates get(); };
public System.Windows.Forms.DataGridViewElementStates State { get; }
member this.State : System.Windows.Forms.DataGridViewElementStates
Public ReadOnly Property State As DataGridViewElementStates
属性值
用于指定单元格状态的 DataGridViewElementStates 值的按位组合。
示例
下面的代码示例演示了此成员的用法。 在此示例中,事件处理程序报告事件的发生情况 DataGridView.CellPainting 。 此报表可帮助你了解事件发生的时间,并可以帮助你进行调试。
若要运行示例代码,请将其粘贴到包含名为 DataGridView1
的 类型的DataGridView实例的项目中。 然后,确保事件处理程序与 DataGridView.CellPainting 事件相关联。
private void DataGridView1_CellPainting(Object sender, DataGridViewCellPaintingEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "AdvancedBorderStyle", e.AdvancedBorderStyle );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CellBounds", e.CellBounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CellStyle", e.CellStyle );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ClipBounds", e.ClipBounds );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "FormattedValue", e.FormattedValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "PaintParts", e.PaintParts );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "State", e.State );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Value", e.Value );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Handled", e.Handled );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellPainting Event" );
}
Private Sub DataGridView1_CellPainting(sender as Object, e as DataGridViewCellPaintingEventArgs) _
Handles DataGridView1.CellPainting
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "AdvancedBorderStyle", e.AdvancedBorderStyle)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "CellBounds", e.CellBounds)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "CellStyle", e.CellStyle)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "ClipBounds", e.ClipBounds)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "ErrorText", e.ErrorText)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "FormattedValue", e.FormattedValue)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Graphics", e.Graphics)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "PaintParts", e.PaintParts)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "State", e.State)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Value", e.Value)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Handled", e.Handled)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"CellPainting Event")
End Sub