DataGridViewElementStates 列舉

定義

指定 DataGridView 控制項內的項目之使用者介面 (UI) 狀態。

此列舉支援其成員值的位元組合。

public enum class DataGridViewElementStates
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum DataGridViewElementStates
[System.Flags]
public enum DataGridViewElementStates
[<System.Flags>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type DataGridViewElementStates = 
[<System.Flags>]
type DataGridViewElementStates = 
Public Enum DataGridViewElementStates
繼承
DataGridViewElementStates
屬性

欄位

Displayed 1

表示某項目目前正顯示在螢幕上。

Frozen 2

表示無法透過 UI 捲動某項目。

None 0

表示某項目位於其預設狀態中。

ReadOnly 4

表示某項目將不會接受使用者輸入來變更它的值。

Resizable 8

表示可以透過 UI 調整某項目的大小。 除非這個值與 ResizableSet 值一起使用,否則會予以忽略。

ResizableSet 16

表示某項目不會繼承其父代的可調整狀態。

Selected 32

表示某項目位於選取的 (反白顯示的) UI 狀態下。

Visible 64

表示某項目為可見 (可顯示)。

範例

下列程式碼範例說明如何使用此類型。 如需詳細資訊,請參閱如何:根據 Windows Forms dataGridView 控制項儲存格中的變更執行自訂動作

private void dataGridView1_CellStateChanged(object sender,
    DataGridViewCellStateChangedEventArgs e)
{
    DataGridViewElementStates state = e.StateChanged;
    string msg = String.Format("Row {0}, Column {1}, {2}",
        e.Cell.RowIndex, e.Cell.ColumnIndex, e.StateChanged);
    MessageBox.Show(msg, "Cell State Changed");
}
Private Sub dataGridView1_CellStateChanged(ByVal sender As Object, _
    ByVal e As DataGridViewCellStateChangedEventArgs) _
    Handles dataGridView1.CellStateChanged

    Dim state As DataGridViewElementStates = e.StateChanged
    Dim msg As String = String.Format( _
        "Row {0}, Column {1}, {2}", _
        e.Cell.RowIndex, e.Cell.ColumnIndex, e.StateChanged)
    MessageBox.Show(msg, "Cell State Changed")

End Sub

備註

雖然 UI 會強制執行這些不同的狀態,例如凍結,但可以程式設計方式覆寫它們。

適用於

另請參閱