DataGridViewElementStates 列舉

定義

指定 DataGridView 控制項內的項目之使用者介面 (UI) 狀態。Specifies the user interface (UI) state of a element within a DataGridView control.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

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

欄位

Displayed 1

表示某項目目前正顯示在螢幕上。Indicates the an element is currently displayed onscreen.

Frozen 2

表示無法透過 UI 捲動某項目。Indicates that an element cannot be scrolled through the UI.

None 0

表示某項目位於其預設狀態中。Indicates that an element is in its default state.

ReadOnly 4

表示某項目將不會接受使用者輸入來變更它的值。Indicates that an element will not accept user input to change its value.

Resizable 8

表示可以透過 UI 調整某項目的大小。Indicates that an element can be resized through the UI. 除非這個值與 ResizableSet 值一起使用,否則會予以忽略。This value is ignored except when combined with the ResizableSet value.

ResizableSet 16

表示某項目不會繼承其父代的可調整狀態。Indicates that an element does not inherit the resizable state of its parent.

Selected 32

表示某項目位於選取的 (反白顯示的) UI 狀態下。Indicates that an element is in a selected (highlighted) UI state.

Visible 64

表示某項目為可見 (可顯示)。Indicates that an element is visible (displayable).

範例

下列程式碼範例說明如何使用此類型。The following code example illustrates the use of this type. 如需詳細資訊,請參閱如何:根據 Windows Forms DataGridView 控制項儲存格的變更執行自訂動作For more information, see How to: Perform a Custom Action Based on Changes in a Cell of a Windows Forms DataGridView Control.

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 強制執行,但它們可以透過程式設計方式來加以使用。Although these different states, like Frozen, are enforced by the UI, they can be programmatically overruled.

適用於

另請參閱