다음을 통해 공유


DataGridViewCheckBoxColumn.IndeterminateValue 속성

정의

비활성화된 확인란으로 표시되는 null 셀 값 또는 결정되지 않은 값에 해당하는 내부 값을 가져오거나 설정합니다.

public:
 property System::Object ^ IndeterminateValue { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))]
public object IndeterminateValue { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.StringConverter))>]
member this.IndeterminateValue : obj with get, set
Public Property IndeterminateValue As Object

속성 값

Object

이 열의 셀에서 결정되지 않은 값으로 처리될 값을 나타내는 Object입니다. 기본값은 null입니다.

특성

예외

CellTemplate 속성의 값이 null인 경우

예제

다음 코드 예제에서는 사무실 조명의 상태를 추적 하는 데 사용 DataGridViewCheckBoxColumn 합니다. 속성은 "turnedOff"와 false연결하고, TrueValue 속성은 FalseValue "turnedOn"을 연결true하고IndeterminateValue, 속성은 "알 수 없음"을 연결하여 확정하지 않습니다.

#using <System.Windows.Forms.dll>
#using <System.dll>
#using <System.Drawing.dll>
using namespace System;
using namespace System::IO;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;

public enum class LightStatus
{
    Unknown,
    TurnedOn,
    TurnedOff
};

public ref class TriValueVirtualCheckBox: public Form
{
private:
    DataGridView^ dataGridView1;

private:
    const int initialSize;

private:
    Dictionary<int, LightStatus>^ store;

public:
    TriValueVirtualCheckBox() :  Form(), initialSize(500)
    {
        dataGridView1 = gcnew DataGridView();
        store = gcnew Dictionary<int, LightStatus>();
        Text = this->GetType()->Name;

        for(int i = 0; i < initialSize; i++)
        {
            store->Add(i, LightStatus::Unknown);
        }

        Controls->Add(dataGridView1);
        dataGridView1->VirtualMode = true;
        dataGridView1->AllowUserToDeleteRows = false;
        dataGridView1->CellValueNeeded += 
            gcnew DataGridViewCellValueEventHandler(
            this, &TriValueVirtualCheckBox::dataGridView1_CellValueNeeded);
        dataGridView1->CellValuePushed += 
            gcnew DataGridViewCellValueEventHandler(
            this, &TriValueVirtualCheckBox::dataGridView1_CellValuePushed);

        dataGridView1->Columns->Add(CreateCheckBoxColumn());
        dataGridView1->Rows->AddCopies(0, initialSize);
    }

private:
    DataGridViewCheckBoxColumn^ CreateCheckBoxColumn()
    {
        DataGridViewCheckBoxColumn^ dataGridViewCheckBoxColumn1
            = gcnew DataGridViewCheckBoxColumn();
        dataGridViewCheckBoxColumn1->HeaderText = "Lights On";
        dataGridViewCheckBoxColumn1->TrueValue = LightStatus::TurnedOn;
        dataGridViewCheckBoxColumn1->FalseValue =
            LightStatus::TurnedOff;
        dataGridViewCheckBoxColumn1->IndeterminateValue
            = LightStatus::Unknown;
        dataGridViewCheckBoxColumn1->ThreeState = true;
        dataGridViewCheckBoxColumn1->ValueType = LightStatus::typeid;
        return dataGridViewCheckBoxColumn1;
    }

#pragma region "data store maintance"
private:
    void dataGridView1_CellValueNeeded(Object^ sender,
        DataGridViewCellValueEventArgs^ e)
    {
        e->Value = store[e->RowIndex];
    }

private:
    void dataGridView1_CellValuePushed(Object^ sender,
        DataGridViewCellValueEventArgs^ e)
    {
        store[e->RowIndex] = (LightStatus) e->Value;
    }
#pragma endregion

};

[STAThread]
int main()
{
    Application::Run(gcnew TriValueVirtualCheckBox());
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;

public class TriValueVirtualCheckBox:Form
{
    DataGridView dataGridView1 = new DataGridView();

    const int initialSize = 500;

    Dictionary<int, LightStatus> store 
        = new Dictionary<int, LightStatus>();

    public TriValueVirtualCheckBox() : base()
    {        
        Text = this.GetType().Name;

        int index = 0;
        for(index=0; index<=initialSize; index++)
            store.Add(index, LightStatus.Unknown);

        Controls.Add(dataGridView1);
        dataGridView1.VirtualMode = true;
        dataGridView1.AllowUserToDeleteRows = false;
        dataGridView1.CellValueNeeded += new 
            DataGridViewCellValueEventHandler(dataGridView1_CellValueNeeded);
        dataGridView1.CellValuePushed += new 
            DataGridViewCellValueEventHandler(dataGridView1_CellValuePushed);

        dataGridView1.Columns.Add(CreateCheckBoxColumn());
        dataGridView1.Rows.AddCopies(0, initialSize);
    }

    private DataGridViewCheckBoxColumn CreateCheckBoxColumn()
    {
        DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1 
            = new DataGridViewCheckBoxColumn();
        dataGridViewCheckBoxColumn1.HeaderText = "Lights On";
        dataGridViewCheckBoxColumn1.TrueValue = LightStatus.TurnedOn;
        dataGridViewCheckBoxColumn1.FalseValue = LightStatus.TurnedOff;
        dataGridViewCheckBoxColumn1.IndeterminateValue 
            = LightStatus.Unknown;
        dataGridViewCheckBoxColumn1.ThreeState = true;
        dataGridViewCheckBoxColumn1.ValueType = typeof(LightStatus);
        return dataGridViewCheckBoxColumn1;
    }

#region "data store maintance"
    private void dataGridView1_CellValueNeeded(object sender, 
        DataGridViewCellValueEventArgs e)
    {
        e.Value = store[e.RowIndex];
    }

    private void dataGridView1_CellValuePushed(object sender, 
        DataGridViewCellValueEventArgs e)
    {
        store[e.RowIndex] = (LightStatus) e.Value;
    }
#endregion

    [STAThreadAttribute()]
    public static void Main()
    {
        Application.Run(new TriValueVirtualCheckBox());
    }
}

public enum LightStatus
{
    Unknown, 
    TurnedOn, 
    TurnedOff
};
Imports System.IO
Imports System.Collections.Generic
Imports System.Windows.Forms

Public Class TriValueVirtualCheckBox
    Inherits System.Windows.Forms.Form

    Dim WithEvents dataGridView1 As New DataGridView

    Const initialSize As Integer = 500

    Dim store As New Dictionary(Of Integer, LightStatus)

    Public Sub New()
        MyBase.New()
        Text = Me.GetType().Name

        Dim index As Integer = 0
        For index = 0 To initialSize
            store.Add(index, LightStatus.Unknown)
        Next

        Controls.Add(dataGridView1)
        dataGridView1.VirtualMode = True
        dataGridView1.AllowUserToDeleteRows = False
        dataGridView1.Columns.Add(CreateCheckBoxColumn())
        dataGridView1.Rows.AddCopies(0, initialSize)
    End Sub

    Private Function CreateCheckBoxColumn() As DataGridViewCheckBoxColumn
        Dim dataGridViewCheckBoxColumn1 _
            As New DataGridViewCheckBoxColumn()
        dataGridViewCheckBoxColumn1.HeaderText = "Lights On"
        dataGridViewCheckBoxColumn1.TrueValue = LightStatus.TurnedOn
        dataGridViewCheckBoxColumn1.FalseValue = LightStatus.TurnedOff
        dataGridViewCheckBoxColumn1.IndeterminateValue = _
            LightStatus.Unknown
        dataGridViewCheckBoxColumn1.ThreeState = True
        dataGridViewCheckBoxColumn1.ValueType = GetType(LightStatus)
        Return dataGridViewCheckBoxColumn1
    End Function

#Region "data store maintance"
    Private Sub dataGridView1_CellValueNeeded(ByVal sender As Object, _
        ByVal e As DataGridViewCellValueEventArgs) _
        Handles dataGridView1.CellValueNeeded

        e.Value = store(e.RowIndex)
    End Sub

    Private Sub dataGridView1_CellValuePushed(ByVal sender As Object, _
        ByVal e As DataGridViewCellValueEventArgs) _
        Handles dataGridView1.CellValuePushed

        store.Item(e.RowIndex) = CType(e.Value, LightStatus)
    End Sub
#End Region

    <STAThreadAttribute()> _
    Public Shared Sub Main()
        Application.Run(New TriValueVirtualCheckBox())
    End Sub
End Class

Public Enum LightStatus
    Unknown
    TurnedOn
    TurnedOff
End Enum

설명

, TrueValueIndeterminateValue 속성은 FalseValue기본 데이터 원본에서 발생하는 이러한 상태의 관련 값을 결정합니다.

이 속성을 가져오거나 설정하면 속성에서 반환 CellTemplateIndeterminateValue 셀 개체의 속성을 가져오거나 설정합니다. 이 속성을 설정 집합을 IndeterminateValue 속성 새로 고침 및 열에 있는 모든 셀의 열을 표시 합니다. 열 값을 설정 하면 개별 셀에 대해 지정된 된 값을 재정의 하려면 셀 값을 설정 합니다.

적용 대상

추가 정보