DataGridViewCellParsingEventArgs.InheritedCellStyle 屬性

定義

取得或設定編輯的儲存格所套用的樣式。

public:
 property System::Windows::Forms::DataGridViewCellStyle ^ InheritedCellStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); void set(System::Windows::Forms::DataGridViewCellStyle ^ value); };
public System.Windows.Forms.DataGridViewCellStyle InheritedCellStyle { get; set; }
public System.Windows.Forms.DataGridViewCellStyle? InheritedCellStyle { get; set; }
member this.InheritedCellStyle : System.Windows.Forms.DataGridViewCellStyle with get, set
Public Property InheritedCellStyle As DataGridViewCellStyle

屬性值

DataGridViewCellStyle,表示正在編輯的儲存格之目前樣式。 預設值是儲存格 InheritedStyle 屬性的值。

範例

下列程式碼範例示範如何使用這個成員。 在此範例中,事件處理常式會報告事件的發生次數 DataGridView.CellParsing 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼入包含名為 DataGridView1 之類型 DataGridView 實例的專案。 然後,確定事件處理常式與 事件相關聯 DataGridView.CellParsing

private void DataGridView1_CellParsing(Object sender, DataGridViewCellParsingEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "InheritedCellStyle", e.InheritedCellStyle );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "ParsingApplied", e.ParsingApplied );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Value", e.Value );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellParsing Event" );
}
Private Sub DataGridView1_CellParsing(sender as Object, e as DataGridViewCellParsingEventArgs) _ 
     Handles DataGridView1.CellParsing

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "InheritedCellStyle", e.InheritedCellStyle)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "ParsingApplied", e.ParsingApplied)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Value", e.Value)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "DesiredType", e.DesiredType)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"CellParsing Event")

End Sub

備註

您可以使用這個屬性來判斷儲存格的效果格式。 設定這個屬性或變更這個屬性傳回的物件屬性沒有任何作用, ParsingAppliedfalse 除非 是 事件處理常式結束時。 在此情況下,會 NullValue 使用儲存格樣式的 、 DataSourceNullValueFormatProvider 屬性來剖析儲存格值。

適用於

另請參閱