DataGridBoolColumnとは? わかりやすく解説

DataGridBoolColumn イベント


パブリック イベントパブリック イベント

  名前 説明
パブリック イベント AlignmentChanged  Alignment プロパティの値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント AllowNullChanged AllowNull プロパティが変更されると発生します。
パブリック イベント Disposed  コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。 ( Component から継承されます。)
パブリック イベント FalseValueChanged FalseValue プロパティが変更されると発生します。
パブリック イベント FontChanged  列のフォントが変更されたときに発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント HeaderTextChanged  HeaderText プロパティの値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント MappingNameChanged  MappingName の値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント NullTextChanged  NullText の値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント PropertyDescriptorChanged  PropertyDescriptor プロパティの値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント ReadOnlyChanged  ReadOnly プロパティの値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
パブリック イベント TrueValueChanged TrueValue プロパティが変更されると発生します。
パブリック イベント WidthChanged  Width プロパティの値が変更された場合に発生します。 ( DataGridColumnStyle から継承されます。)
参照参照

関連項目

DataGridBoolColumn クラス
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
GetType
Type

DataGridBoolColumn クラス

各セルで Boolean 値を表すためのチェック ボックスを格納する列を指定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class DataGridBoolColumn
    Inherits DataGridColumnStyle
Dim instance As DataGridBoolColumn
public class DataGridBoolColumn : DataGridColumnStyle
public ref class DataGridBoolColumn : public
 DataGridColumnStyle
public class DataGridBoolColumn extends DataGridColumnStyle
public class DataGridBoolColumn extends
 DataGridColumnStyle
解説解説

DataGridBoolColumn は、abstract クラスの DataGridColumnStyle から派生します。実行時、DataGridBoolColumn には、既定で各セルにオン (true)、オフ (false)、Value の 3 つの状態を持つチェック ボックスが格納されます。状態が 2 種類のチェック ボックスを使用するには、AllowNull プロパティを false に設定します。

このクラスに追加されたプロパティには、FalseValue、NullValue、および TrueValue があります。これらのプロパティでは、列の各状態に基づいた値を指定します。

使用例使用例

新しい DataGridBoolColumn を作成し、DataGridTableStyle の GridColumnStylesCollection に追加するコード例を次に示します。

Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel

Public Class MyForm
    Inherits System.Windows.Forms.Form
    Private components As System.ComponentModel.Container
    Private myTable As DataTable
    Private myGrid As DataGrid = New
 DataGrid()

    Public Shared Sub Main()
        Application.Run(New MyForm())
    End Sub

    Public Sub New()
        Try
            InitializeComponent()
            myTable = New DataTable("NamesTable")
            myTable.Columns.Add(New DataColumn("Name"))
            Dim column As DataColumn = New
 DataColumn _
            ("id", GetType(System.Int32))
            myTable.Columns.Add(column)
            myTable.Columns.Add(New DataColumn _
            ("calculatedField", GetType(Boolean)))
            Dim namesDataSet As DataSet = New
 DataSet("myDataSet")
            namesDataSet.Tables.Add(myTable)
            myGrid.SetDataBinding(namesDataSet, "NamesTable")
            AddData()
            AddTableStyle()

        Catch exc As System.Exception
            Console.WriteLine(exc.ToString)
        End Try
    End Sub

    Private Sub AddTableStyle()
        ' Map a new  TableStyle to the DataTable. Then 
        ' add DataGridColumnStyle objects to the collection
        ' of column styles with appropriate mappings.
        Dim dgt As DataGridTableStyle = New
 DataGridTableStyle()
        dgt.MappingName = "NamesTable"

        Dim dgtbc As DataGridTextBoxColumn
 = _
        New DataGridTextBoxColumn()
        dgtbc.MappingName = "Name"
        dgtbc.HeaderText = "Name"
        dgt.GridColumnStyles.Add(dgtbc)

        dgtbc = New DataGridTextBoxColumn()
        dgtbc.MappingName = "id"
        dgtbc.HeaderText = "id"
        dgt.GridColumnStyles.Add(dgtbc)

        Dim db As DataGridBoolColumnInherit
 = _
        New DataGridBoolColumnInherit()
        db.HeaderText = "less than 1000 = blue"
        db.Width = 150
        db.MappingName = "calculatedField"
        dgt.GridColumnStyles.Add(db)

        myGrid.TableStyles.Add(dgt)

        ' This expression instructs the grid to change
        ' the color of the inherited DataGridBoolColumn
        ' according to the value of the id field. If it's
        ' less than 1000, the row is blue. Otherwise,
        ' the color is yellow.
        db.Expression = "id < 1000"
    End Sub

    Private Sub AddData()

        ' Add data with varying numbers for the id field.
        ' If the number is over 1000, the cell will paint
        ' yellow. Otherwise, it will be blue.
        Dim dRow As DataRow

        dRow = myTable.NewRow()
        dRow("Name") = "name 1"
        dRow("id") = 999
        myTable.Rows.Add(dRow)

        dRow = myTable.NewRow()
        dRow("Name") = "name 2"
        dRow("id") = 2300
        myTable.Rows.Add(dRow)

        dRow = myTable.NewRow()
        dRow("Name") = "name 3"
        dRow("id") = 120
        myTable.Rows.Add(dRow)

        dRow = myTable.NewRow()
        dRow("Name") = "name 4"
        dRow("id") = 4023
        myTable.Rows.Add(dRow)

        dRow = myTable.NewRow()
        dRow("Name") = "name 5"
        dRow("id") = 2345
        myTable.Rows.Add(dRow)

        myTable.AcceptChanges()
    End Sub

    Private Sub InitializeComponent()
        Me.Size = New Size(500, 500)
        myGrid.Size = New Size(350, 250)
        myGrid.TabStop = True
        myGrid.TabIndex = 1
        Me.StartPosition = FormStartPosition.CenterScreen
        Me.Controls.Add(myGrid)
    End Sub

End Class


Public Class DataGridBoolColumnInherit
    Inherits DataGridBoolColumn

    Private trueBrush As SolidBrush = Brushes.Blue
    Private falseBrush As SolidBrush = Brushes.Yellow
    Private expressionColumn As DataColumn
 = Nothing
    Shared count As Int32 = 0

    Public Property FalseColor() As
 Color
        Get
            Return falseBrush.Color
        End Get

        Set(ByVal Value As
 Color)

            falseBrush = New SolidBrush(Value)
            Invalidate()
        End Set
    End Property

    Public Property TrueColor() As
 Color
        Get
            Return trueBrush.Color
        End Get

        Set(ByVal Value As
 Color)

            trueBrush = New SolidBrush(Value)
            Invalidate()
        End Set
    End Property

    Public Sub New()
        count += 1
    End Sub

    ' This will work only with a DataSet or DataTable.
    ' The code is not compatible with IBindingList implementations.
    Public Property Expression() As
 String
        Get
            If Me.expressionColumn Is
 Nothing Then
                Return String.Empty
            Else
                Return Me.expressionColumn.Expression
            End If
        End Get
        Set(ByVal Value As
 String)
            If expressionColumn Is Nothing
 Then
                AddExpressionColumn(Value)
            Else
                expressionColumn.Expression = Value
            End If
            If Not (expressionColumn Is
 Nothing) And expressionColumn.Expression.Equals(Value)
 Then
                Return
            End If
            Invalidate()
        End Set
    End Property

    Private Sub AddExpressionColumn(ByVal
 value As String)
        ' Get the grid's data source. First check for a null 
        ' table or data grid.
        If Me.DataGridTableStyle Is
 Nothing Or _
        Me.DataGridTableStyle.DataGrid Is Nothing
 Then
            Return
        End If

        Dim dg As DataGrid = Me.DataGridTableStyle.DataGrid
        Dim dv As DataView = CType(dg.BindingContext(dg.DataSource,
 dg.DataMember), CurrencyManager).List

        ' This works only with System.Data.DataTable.
        If dv Is Nothing
 Then
            Return
        End If

        ' If the user already added a column with the name 
        ' then exit. Otherwise, add the column and set the 
        ' expression to the value passed to this function.
        Dim col As DataColumn = dv.Table.Columns("__Computed__Column__")
        If Not (col Is Nothing)
 Then
            Return
        End If
        col = New DataColumn("__Computed__Column__"
 + count.ToString())

        dv.Table.Columns.Add(col)

        col.Expression = value
        expressionColumn = col
    End Sub


    ' Override the OnPaint method to paint the cell based on the expression.
    Protected Overloads Overrides
 Sub Paint _
    (ByVal g As Graphics, _
    ByVal bounds As Rectangle, _
    ByVal [source] As CurrencyManager, _
    ByVal rowNum As Integer,
 _
    ByVal backBrush As Brush, _
    ByVal foreBrush As Brush, _
    ByVal alignToRight As Boolean)
        Dim trueExpression As Boolean
 = False
        Dim hasExpression As Boolean
 = False
        Dim drv As DataRowView = [source].List(rowNum)
        hasExpression = Not (Me.expressionColumn
 Is Nothing) And Not
 (Me.expressionColumn.Expression Is Nothing) And Not Me.expressionColumn.Expression.Equals([String].Empty)

        ' Get the value from the expression column.
        ' For simplicity, we assume a True/False value for the 
        ' expression column.
        If hasExpression Then
            Dim expr As Object
 = drv.Row(expressionColumn.ColumnName)
            trueExpression = expr.Equals("True")
        End If

        ' Let the DataGridBoolColumn do the painting.
        If Not hasExpression Then
            MyBase.Paint(g, bounds, [source], rowNum, backBrush,
 foreBrush, alignToRight)
        End If

        ' Paint using the expression color for true or false, as calculated.
        If trueExpression Then
            MyBase.Paint(g, bounds, [source], rowNum, trueBrush,
 foreBrush, alignToRight)
        Else
            MyBase.Paint(g, bounds, [source], rowNum, falseBrush,
 foreBrush, alignToRight)
        End If
    End Sub
End Class
using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

public class MyForm : Form 
{
    private DataTable myTable;
    private DataGrid myGrid = new DataGrid();
    
    public MyForm() : base() 
    {
        try
        {
            InitializeComponent();

            myTable = new DataTable("NamesTable");
            myTable.Columns.Add(new DataColumn("Name"));
            DataColumn column = new DataColumn
                ("id", typeof(System.Int32));
            myTable.Columns.Add(column);
            myTable.Columns.Add(new 
                DataColumn("calculatedField", typeof(bool)));
            DataSet namesDataSet = new DataSet();
            namesDataSet.Tables.Add(myTable);
            myGrid.SetDataBinding(namesDataSet, "NamesTable");
        
            AddTableStyle();
            AddData();
        }
        catch (System.Exception exc)
        {
            Console.WriteLine(exc.ToString());
        }
    }

    
    private void grid_Enter(object sender,
 EventArgs e) 
    {
        myGrid.CurrentCell = new DataGridCell(2,2);
    }

    private void AddTableStyle()
    {
        // Map a new  TableStyle to the DataTable. Then 
        // add DataGridColumnStyle objects to the collection
        // of column styles with appropriate mappings.
        DataGridTableStyle dgt = new DataGridTableStyle();
        dgt.MappingName = "NamesTable";

        DataGridTextBoxColumn dgtbc = new DataGridTextBoxColumn();
        dgtbc.MappingName = "Name";
        dgtbc.HeaderText= "Name";
        dgt.GridColumnStyles.Add(dgtbc);

        dgtbc = new DataGridTextBoxColumn();
        dgtbc.MappingName = "id";
        dgtbc.HeaderText= "id";
        dgt.GridColumnStyles.Add(dgtbc);

        DataGridBoolColumnInherit db = 
            new DataGridBoolColumnInherit();
        db.HeaderText= "less than 1000 = blue";
        db.Width= 150;
        db.MappingName = "calculatedField";
        dgt.GridColumnStyles.Add(db);

        myGrid.TableStyles.Add(dgt);

        // This expression instructs the grid to change
        // the color of the inherited DataGridBoolColumn
        // according to the value of the id field. If it's
        // less than 1000, the row is blue. Otherwise,
        // the color is yellow.
        db.Expression = "id < 1000";
    }

    private void AddData() 
    {
        // Add data with varying numbers for the id field.
        // If the number is over 1000, the cell will paint
        // yellow. Otherwise, it will be blue.
        DataRow dRow = myTable.NewRow();

        dRow["Name"] = "name 1 ";
        dRow["id"] = 999;
        myTable.Rows.Add(dRow);

        dRow = myTable.NewRow();
        dRow["Name"] = "name 2";
        dRow["id"] = 2300;
        myTable.Rows.Add(dRow);

        dRow = myTable.NewRow();
        dRow["Name"] = "name 3";
        dRow["id"] = 120;
        myTable.Rows.Add(dRow);

        dRow = myTable.NewRow();
        dRow["Name"] = "name 4";
        dRow["id"] = 4023;
        myTable.Rows.Add(dRow);

        dRow = myTable.NewRow();
        dRow["Name"] = "name 5";
        dRow["id"] = 2345;
        myTable.Rows.Add(dRow);

        myTable.AcceptChanges();
    }

    private void InitializeComponent() 
    {
        this.Size = new Size(500, 500);
        myGrid.Size = new Size(350, 250);
        myGrid.TabStop = true;
        myGrid.TabIndex = 1;
      
        this.StartPosition = FormStartPosition.CenterScreen;
        this.Controls.Add(myGrid);
      }
    [STAThread]
    public static void Main()
 
    {
        MyForm myGridForm = new MyForm();
        myGridForm.ShowDialog();
    }
}

public class DataGridBoolColumnInherit : DataGridBoolColumn
 
{
    private SolidBrush trueBrush = Brushes.Blue as SolidBrush;
    private SolidBrush falseBrush = Brushes.Yellow as SolidBrush;
    private DataColumn expressionColumn = null;
    private static int count
 = 0;

    public Color FalseColor 
    {
        get 
        {
            return falseBrush.Color;
        }
        set 
        {
            falseBrush = new SolidBrush(value);
            Invalidate();
        }
    }

    public Color TrueColor 
    {
        get 
        {
            return trueBrush.Color;
        }
        set 
        {
            trueBrush = new SolidBrush(value);
            Invalidate();
        }
    }

    public DataGridBoolColumnInherit() : base
 () 
    {
        count ++;
    }


    // This will work only with a DataSet or DataTable.
    // The code is not compatible with IBindingList implementations.
    public string Expression 
    {
        get 
        {
            return this.expressionColumn ==
 null ? String.Empty : 
                this.expressionColumn.Expression;
        }
        set 
        {
            if (expressionColumn == null)
                AddExpressionColumn(value);
            else 
                expressionColumn.Expression = value;
            if (expressionColumn != null &&
 
                expressionColumn.Expression.Equals(value))
                return;
            Invalidate();
        }
    }

    private void AddExpressionColumn(string
 value) 
    {
        // Get the grid's data source. First check for a null 
        // table or data grid.
        if (this.DataGridTableStyle == null
 || 
            this.DataGridTableStyle.DataGrid == null)
            return;

        DataGrid myGrid = this.DataGridTableStyle.DataGrid;
        DataView myDataView = ((CurrencyManager) 
            myGrid.BindingContext[myGrid.DataSource, 
            myGrid.DataMember]).List 
            as DataView;

        // This works only with System.Data.DataTable.
        if (myDataView == null)
            return;

        // If the user already added a column with the name 
        // then exit. Otherwise, add the column and set the 
        // expression to the value passed to this function.
        DataColumn col = myDataView.Table.Columns["__Computed__Column__"];
        if (col != null)
            return;
        col = new DataColumn("__Computed__Column__"
 + count.ToString());

        myDataView.Table.Columns.Add(col);
        col.Expression = value;
        expressionColumn = col;
    }

    // override the OnPaint method to paint the cell based on the expression.
    protected override void Paint(Graphics
 g, Rectangle bounds,
        CurrencyManager source, int rowNum,
        Brush backBrush, Brush foreBrush,
        bool alignToRight) 
    {
        bool trueExpression = false;
        bool hasExpression = false;
        DataRowView drv = source.List[rowNum] as DataRowView;

        hasExpression = this.expressionColumn != null
 && 
            this.expressionColumn.Expression != null
 && 
            !this.expressionColumn.Expression.Equals(String.Empty);

        Console.WriteLine(string.Format("hasExpressionValue
 {0}",hasExpression));
        // Get the value from the expression column.
        // For simplicity, we assume a True/False value for the 
        // expression column.
        if (hasExpression) 
        {
            object expr = drv.Row[expressionColumn.ColumnName];
            trueExpression = expr.Equals("True");
        }

        // Let the DataGridBoolColumn do the painting.
        if (!hasExpression)
            base.Paint(g, bounds, source, rowNum, 
                backBrush, foreBrush, alignToRight);

        // Paint using the expression color for true or false, as calculated.
        if (trueExpression)
            base.Paint(g, bounds, source, rowNum, 
                trueBrush, foreBrush, alignToRight);
        else
            base.Paint(g, bounds, source, rowNum, 
                falseBrush, foreBrush, alignToRight);
    }
}
using namespace System;
using namespace System::Data;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::ComponentModel;

public ref class DataGridBoolColumnInherit:
 public DataGridBoolColumn
{
private:
   SolidBrush^ trueBrush;
   SolidBrush^ falseBrush;
   DataColumn^ expressionColumn;
   static int count = 0;

public:
   DataGridBoolColumnInherit()
      : DataGridBoolColumn()
   {
      trueBrush = dynamic_cast<SolidBrush^>(Brushes::Blue);
      falseBrush = dynamic_cast<SolidBrush^>(Brushes::Yellow);
      expressionColumn = nullptr;
      count++;
   }

   property Color FalseColor 
   {
      Color get()
      {
         return falseBrush->Color;
      }

      void set( Color value )
      {
         falseBrush = gcnew System::Drawing::SolidBrush( value );
         Invalidate();
      }
   }

   property Color TrueColor 
   {
      Color get()
      {
         return trueBrush->Color;
      }

      void set( Color value )
      {
         trueBrush = gcnew System::Drawing::SolidBrush( value );
         Invalidate();
      }
   }

   property String^ Expression 
   {
      // This will work only with a DataSet or DataTable.
      // The code is not compatible with IBindingList* implementations.
      String^ get()
      {
         return this->expressionColumn ==
 nullptr ? String::Empty : this->expressionColumn->Expression;
      }

      void set( String^ value )
      {
         if ( expressionColumn == nullptr )
                  AddExpressionColumn( value );
         else
                  expressionColumn->Expression = value;

         if ( expressionColumn != nullptr && expressionColumn->Expression->Equals(
 value ) )
                  return;

         Invalidate();
      }
   }

private:
   void AddExpressionColumn( String^ value )
   {
      // Get the grid's data source. First check for a 0 
      // table or data grid.
      if ( this->DataGridTableStyle == nullptr
 || this->DataGridTableStyle->DataGrid == nullptr )
            return;

      DataGrid^ myGrid = this->DataGridTableStyle->DataGrid;
      DataView^ myDataView = dynamic_cast<DataView^>((dynamic_cast<CurrencyManager^>(myGrid->BindingContext[
 myGrid->DataSource,myGrid->DataMember ]))->List);

      // This works only with System::Data::DataTable.
      if ( myDataView == nullptr )
            return;

      // If the user already added a column with the name 
      // then exit. Otherwise, add the column and set the 
      // expression to the value passed to this function.
      DataColumn^ col = myDataView->Table->Columns[ "__Computed__Column__"
 ];
      if ( col != nullptr )
            return;

      col = gcnew DataColumn( String::Concat( "__Computed__Column__", count
 ) );
      myDataView->Table->Columns->Add( col );
      col->Expression = value;
      expressionColumn = col;
   }

   //  the OnPaint method to paint the cell based on the expression.
protected:
   virtual void Paint( Graphics^ g, Rectangle bounds, CurrencyManager^
 source, int rowNum, Brush^ backBrush, Brush^ foreBrush, bool
 alignToRight ) override
   {
      bool trueExpression = false;
      bool hasExpression = false;
      DataRowView^ drv = dynamic_cast<DataRowView^>(source->List[ rowNum
 ]);
      hasExpression = this->expressionColumn != nullptr &&
 this->expressionColumn->Expression != nullptr &&
  !this->expressionColumn->Expression->Equals( String::Empty );
      Console::WriteLine( String::Format( "hasExpressionValue {0}", hasExpression
 ) );

      // Get the value from the expression column.
      // For simplicity, we assume a True/False value for the 
      // expression column.
      if ( hasExpression )
      {
         Object^ expr = drv->Row[ expressionColumn->ColumnName ];
         trueExpression = expr->Equals( "True" );
      }

      // Let the DataGridBoolColumn do the painting.
      if (  !hasExpression )
            DataGridBoolColumn::Paint( g, bounds, source, rowNum, backBrush, foreBrush,
 alignToRight );

      // Paint using the expression color for true or false, as calculated.
      if ( trueExpression )
            DataGridBoolColumn::Paint( g, bounds, source, rowNum, trueBrush, foreBrush,
 alignToRight );
      else
            DataGridBoolColumn::Paint( g, bounds, source, rowNum, falseBrush, foreBrush,
 alignToRight );
   }
};

public ref class MyForm: public
 Form
{
private:
   DataTable^ myTable;
   DataGrid^ myGrid;

public:
   MyForm()
   {
      myGrid = gcnew DataGrid;
      try
      {
         InitializeComponent();
         myTable = gcnew DataTable( "NamesTable" );
         myTable->Columns->Add( gcnew DataColumn( "Name" ) );
         DataColumn^ column = gcnew DataColumn( "id",Int32::typeid );
         myTable->Columns->Add( column );
         myTable->Columns->Add( gcnew DataColumn( "calculatedField",bool::typeid
 ) );
         DataSet^ namesDataSet = gcnew DataSet;
         namesDataSet->Tables->Add( myTable );
         myGrid->SetDataBinding( namesDataSet, "NamesTable" );
         AddTableStyle();
         AddData();
      }
      catch ( System::Exception^ exc ) 
      {
         Console::WriteLine( exc );
      }
   }

private:
   void grid_Enter( Object^ sender, EventArgs^ e )
   {
      myGrid->CurrentCell = DataGridCell(2,2);
   }

   void AddTableStyle()
   {
      // Map a new  TableStyle to the DataTable. Then 
      // add DataGridColumnStyle objects to the collection
      // of column styles with appropriate mappings.
      DataGridTableStyle^ dgt = gcnew DataGridTableStyle;
      dgt->MappingName = "NamesTable";
      DataGridTextBoxColumn^ dgtbc = gcnew DataGridTextBoxColumn;
      dgtbc->MappingName = "Name";
      dgtbc->HeaderText = "Name";
      dgt->GridColumnStyles->Add( dgtbc );
      dgtbc = gcnew DataGridTextBoxColumn;
      dgtbc->MappingName = "id";
      dgtbc->HeaderText = "id";
      dgt->GridColumnStyles->Add( dgtbc );
      DataGridBoolColumnInherit^ db = gcnew DataGridBoolColumnInherit;
      db->HeaderText = "less than 1000 = blue";
      db->Width = 150;
      db->MappingName = "calculatedField";
      dgt->GridColumnStyles->Add( db );
      myGrid->TableStyles->Add( dgt );

      // This expression instructs the grid to change
      // the color of the inherited DataGridBoolColumn
      // according to the value of the id field. If it's
      // less than 1000, the row is blue. Otherwise,
      // the color is yellow.
      db->Expression = "id < 1000";
   }

   void AddData()
   {
      // Add data with varying numbers for the id field.
      // If the number is over 1000, the cell will paint
      // yellow. Otherwise, it will be blue.
      DataRow^ dRow = myTable->NewRow();
      dRow[ "Name" ] = "name 1 ";
      dRow[ "id" ] = 999;
      myTable->Rows->Add( dRow );
      dRow = myTable->NewRow();
      dRow[ "Name" ] = "name 2";
      dRow[ "id" ] = 2300;
      myTable->Rows->Add( dRow );
      dRow = myTable->NewRow();
      dRow[ "Name" ] = "name 3";
      dRow[ "id" ] = 120;
      myTable->Rows->Add( dRow );
      dRow = myTable->NewRow();
      dRow[ "Name" ] = "name 4";
      dRow[ "id" ] = 4023;
      myTable->Rows->Add( dRow );
      dRow = myTable->NewRow();
      dRow[ "Name" ] = "name 5";
      dRow[ "id" ] = 2345;
      myTable->Rows->Add( dRow );
      myTable->AcceptChanges();
   }

   void InitializeComponent()
   {
      this->Size = System::Drawing::Size( 500, 500 );
      myGrid->Size = System::Drawing::Size( 350, 250 );
      myGrid->TabStop = true;
      myGrid->TabIndex = 1;
      this->StartPosition = FormStartPosition::CenterScreen;
      this->Controls->Add( myGrid );
   }
};

[STAThread]
int main()
{
   MyForm^ myGridForm = gcnew MyForm;
   myGridForm->ShowDialog();
}
import System.*;
import System.Data.*;
import System.Windows.Forms.*;
import System.Drawing.*;
import System.ComponentModel.*;

public class MyForm extends Form
{
    private DataTable myTable;
    private DataGrid myGrid = new DataGrid();

    public MyForm()
    {
        try {
            InitializeComponent();
            myTable = new DataTable("NamesTable");
            myTable.get_Columns().Add(new DataColumn("Name"));

            DataColumn column = 
                new DataColumn("id", System.Int32.class.ToType());

            myTable.get_Columns().Add(column);
            myTable.get_Columns().Add(new DataColumn("calculatedField",
 
                boolean.class.ToType()));

            DataSet namesDataSet = new DataSet();

            namesDataSet.get_Tables().Add(myTable);
            myGrid.SetDataBinding(namesDataSet, "NamesTable");
            AddTableStyle();
            AddData();
        }
        catch(System.Exception exc) {
            Console.WriteLine(exc.ToString());
        }
    } //MyForm

    private void gridEnter(Object sender, EventArgs
 e)
    {
        myGrid.set_CurrentCell(new DataGridCell(2, 2));
    } //gridEnter

    private void AddTableStyle()
    {
        // Map a new  TableStyle to the DataTable. Then 
        // add DataGridColumnStyle objects to the collection
        // of column styles with appropriate mappings.
        DataGridTableStyle dgt = new DataGridTableStyle();

        dgt.set_MappingName("NamesTable");

        DataGridTextBoxColumn dgtbc = new DataGridTextBoxColumn();

        dgtbc.set_MappingName("Name");
        dgtbc.set_HeaderText("Name");
        dgt.get_GridColumnStyles().Add(dgtbc);
        dgtbc = new DataGridTextBoxColumn();
        dgtbc.set_MappingName("id");
        dgtbc.set_HeaderText("id");
        dgt.get_GridColumnStyles().Add(dgtbc);

        DataGridBoolColumnInherit db = new DataGridBoolColumnInherit();

        db.set_HeaderText("less than 1000 = blue");
        db.set_Width(150);
        db.set_MappingName("calculatedField");
        dgt.get_GridColumnStyles().Add(db);
        myGrid.get_TableStyles().Add(dgt);

        // This expression instructs the grid to change
        // the color of the inherited DataGridBoolColumn
        // according to the value of the id field. If it's
        // less than 1000, the row is blue. Otherwise,
        // the color is yellow.
        db.set_Expression("id < 1000");
    } //AddTableStyle

    private void AddData()
    {
        // Add data with varying numbers for the id field.
        // If the number is over 1000, the cell will paint
        // yellow. Otherwise, it will be blue.
        DataRow dRow = myTable.NewRow();

        dRow.set_Item("Name", "name 1 ");
        dRow.set_Item("id", (Int32)999);
        myTable.get_Rows().Add(dRow);
        dRow = myTable.NewRow();
        dRow.set_Item("Name", "name 2");
        dRow.set_Item("id", (Int32)2300);
        myTable.get_Rows().Add(dRow);
        dRow = myTable.NewRow();
        dRow.set_Item("Name", "name 3");
        dRow.set_Item("id", (Int32)120);
        myTable.get_Rows().Add(dRow);
        dRow = myTable.NewRow();
        dRow.set_Item("Name", "name 4");
        dRow.set_Item("id", (Int32)4023);
        myTable.get_Rows().Add(dRow);
        dRow = myTable.NewRow();
        dRow.set_Item("Name", "name 5");
        dRow.set_Item("id", (Int32)2345);
        myTable.get_Rows().Add(dRow);
        myTable.AcceptChanges();
    } //AddData

    private void InitializeComponent()
    {
        this.set_Size(new Size(500, 500));
        myGrid.set_Size(new Size(350, 250));
        myGrid.set_TabStop(true);
        myGrid.set_TabIndex(1);
        this.set_StartPosition(FormStartPosition.CenterScreen);
        this.get_Controls().Add(myGrid);
    } //InitializeComponent

    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        MyForm myGridForm = new MyForm();
        myGridForm.ShowDialog();
    } //main
} //MyForm

public class DataGridBoolColumnInherit extends
 DataGridBoolColumn
{
    private SolidBrush trueBrush = (SolidBrush)Brushes.get_Blue();
    private SolidBrush falseBrush = (SolidBrush)Brushes.get_Yellow();
    private DataColumn expressionColumn = null;
    private static int count
 = 0;

    /** @property 
     */
    public Color get_FalseColor()
    {
        return falseBrush.get_Color();
    } //get_FalseColor

    /** @property 
     */
    public void set_FalseColor(Color value)
    {
        falseBrush = new SolidBrush(value);
        Invalidate();
    } //set_FalseColor

    /** @property 
     */
    public Color get_TrueColor()
    {
        return trueBrush.get_Color();
    } //get_TrueColor

    /** @property 
     */
    public void set_TrueColor(Color value)
    {
        trueBrush = new SolidBrush(value);
        Invalidate();
    } //set_TrueColor

    public DataGridBoolColumnInherit()
    {
        super();
        count++;
    } //DataGridBoolColumnInherit

    // This will work only with a DataSet or DataTable.
    // The code is not compatible with IBindingList implementations.
    /** @property 
     */
    public String get_Expression()
    {
        return (this.expressionColumn == null)
 
            ? String.Empty : this.expressionColumn.get_Expression();
    } //get_Expression

    /** @property 
     */
    public void set_Expression(String value)
    {
        if(expressionColumn == null) {
            AddExpressionColumn(value);
        }
        else {
            expressionColumn.set_Expression(value);
        }

        if(expressionColumn != null 
            && expressionColumn.get_Expression().Equals(value)) {
            return;
        }
        Invalidate();
    } //set_Expression

    private void AddExpressionColumn(String
 value)
    {
        // Get the grid's data source. First check for a null 
        // table or data grid.
        if(this.get_DataGridTableStyle() ==
 null 
            || this.get_DataGridTableStyle().get_DataGrid() ==
 null) {
            return;
        }

        DataGrid myGrid = this.get_DataGridTableStyle().get_DataGrid();
        DataView myDataView = (DataView)(((CurrencyManager)(myGrid.
            get_BindingContext().get_Item(myGrid.get_DataSource(), 
            myGrid.get_DataMember()))).get_List());

        // This works only with System.Data.DataTable.
        if(myDataView == null) {
            return;
        }

        // If the user already added a column with the name 
        // then exit. Otherwise, add the column and set the 
        // expression to the value passed to this function.
        DataColumn col = myDataView.get_Table().get_Columns().
            get_Item("__Computed__Column__");

        if(col != null) {
            return;
        }
        col = new DataColumn("__Computed__Column__"
 
            + System.Convert.ToString(count));

        myDataView.get_Table().get_Columns().Add(col);
        col.set_Expression(value);
        expressionColumn = col;
    } //AddExpressionColumn

    // override the OnPaint method to paint the cell based on the expression.
    protected void Paint(Graphics g, Rectangle
 bounds, CurrencyManager source, 
        int rowNum, Brush backBrush, Brush foreBrush, boolean
 alignToRight)
    {
        boolean trueExpression = false;
        boolean hasExpression = false;
        DataRowView drv = (DataRowView)source.get_List().get_Item(rowNum);

        hasExpression = this.expressionColumn != null
 
            && this.expressionColumn.get_Expression()
 != null 
            && !(this.expressionColumn.get_Expression().Equals(String.Empty));
        
        Console.WriteLine(String.Format("hasExpressionValue {0}", 
            System.Convert.ToString(hasExpression)));

        // Get the value from the expression column.
        // For simplicity, we assume a True/False value for the 
        // expression column.
        if(hasExpression) {
            Object expr = 
                drv.get_Row().get_Item(expressionColumn.get_ColumnName());
            trueExpression = expr.Equals("True");
        }

        // Let the DataGridBoolColumn do the painting.
        if(!(hasExpression)) {
            super.Paint(g, bounds, source, rowNum, backBrush, foreBrush, 
                alignToRight);
        }

        // Paint using the expression color for true or false, as calculated.
        if(trueExpression) {
            super.Paint(g, bounds, source, rowNum, trueBrush, foreBrush, 
                alignToRight);
        }
        else {
            super.Paint(g, bounds, source, rowNum, falseBrush, foreBrush, 
                alignToRight);
        }
    } //Paint
} //DataGridBoolColumnInherit
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.DataGridColumnStyle
        System.Windows.Forms.DataGridBoolColumn
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridBoolColumn メンバ
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
GetType
Type

DataGridBoolColumn コンストラクタ ()

DataGridBoolColumn クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As New DataGridBoolColumn
public DataGridBoolColumn ()
public:
DataGridBoolColumn ()
public DataGridBoolColumn ()
public function DataGridBoolColumn ()
解説解説

このオーバーロードを使用して DataGridBoolColumn を作成するときは、MappingName 値を DataColumn の ColumnName に設定してください。

使用例使用例

新しい DataGridBoolColumn を作成し、DataGridTableStyle の GridColumnStylesCollection に追加するコード例を次に示します。

Private Sub AddDataGridBoolColumnStyle()
   Dim myColumn As DataGridBoolColumn  = new
 DataGridBoolColumn()
   myColumn.MappingName = "Current"
   myColumn.Width = 200
   dataGrid1.TableStyles("Customers").GridColumnStyles.Add(myColumn)
End Sub 
private void AddDataGridBoolColumnStyle(){
   DataGridBoolColumn myColumn = new DataGridBoolColumn();
   myColumn.MappingName = "Current";
   myColumn.Width = 200;
   dataGrid1.TableStyles["Customers"].GridColumnStyles.Add(myColumn);
} 
void AddDataGridBoolColumnStyle()
{
   DataGridBoolColumn^ myColumn = gcnew DataGridBoolColumn;
   myColumn->MappingName = "Current";
   myColumn->Width = 200;
   dataGrid1->TableStyles[ "Customers" ]->GridColumnStyles->Add(
 myColumn );
}

private void AddDataGridBoolColumnStyle()
{
    DataGridBoolColumn myColumn = new DataGridBoolColumn();
    myColumn.set_MappingName("Current");
    myColumn.set_Width(200);
    dataGrid1.get_TableStyles().get_Item("Customers").
        get_GridColumnStyles().Add(myColumn);
} //AddDataGridBoolColumnStyle
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridBoolColumn クラス
DataGridBoolColumn メンバ
System.Windows.Forms 名前空間
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
DataColumn

DataGridBoolColumn コンストラクタ (PropertyDescriptor)

PropertyDescriptor を指定して、DataGridBoolColumn の新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

DataGridBoolColumn には、Boolean 値を含むデータ ソースを関連付けてください。

PropertyDescriptor を取得するには、最初に BindingContext を使用して適切な BindingManagerBase を返します。その後、BindingManagerBase の GetItemProperties メソッドを使用して、PropertyDescriptorCollection を返します。最後に、PropertyDescriptorCollection の Item プロパティを使用して、列に特有の PropertyDescriptor を返します。

使用例使用例

GetItemProperties メソッドを使用して、DataTable の System.ComponentModel.PropertyDescriptorCollection を返すコード例を次に示します。その後、DataColumn の PropertyDescriptor を使用して、DataGridBoolColumn を作成します。

Private Sub CreateNewDataGridColumn()
   Dim myGridColumnCol As GridColumnStylesCollection
   myGridColumnCol = dataGrid1.TableStyles(0).GridColumnStyles
   ' Get the CurrencyManager for the table.
   Dim myCurrencyManager As CurrencyManager
 =  _
   CType(Me.BindingContext(ds.Tables("Products")),
 CurrencyManager)
   ' Get the PropertyDescriptor for the DataColumn of the new column.
   ' The column should contain a Boolean value. 
   Dim pd As PropertyDescriptor = _
   myCurrencyManager.GetItemProperties()("Discontinued")
   Dim myColumn As New DataGridBoolColumn(pd)
   myColumn.MappingName = "Discontinued"
   myGridColumnCol.Add(myColumn)
End Sub 
private void CreateNewDataGridColumn(){
   System.Windows.Forms.GridColumnStylesCollection myGridColumnCol;
   myGridColumnCol = dataGrid1.TableStyles[0].GridColumnStyles;
   // Get the CurrencyManager for the table.
   CurrencyManager myCurrencyManager = 
   (CurrencyManager)this.BindingContext[ds.Tables["Products"]];
   /* Get the PropertyDescriptor for the DataColumn of the new
 column.
   The column should contain a Boolean value. */
   PropertyDescriptor pd = myCurrencyManager.
   GetItemProperties()["Discontinued"];
   DataGridColumnStyle myColumn = 
   new System.Windows.Forms.DataGridBoolColumn(pd);
   myColumn.MappingName = "Discontinued";
   myGridColumnCol.Add(myColumn);
}
void CreateNewDataGridColumn()
{
   System::Windows::Forms::GridColumnStylesCollection^ myGridColumnCol;
   myGridColumnCol = dataGrid1->TableStyles[ 0 ]->GridColumnStyles;
   
   // Get the CurrencyManager for the table.
   CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[
 ds->Tables[ "Products" ] ]);
   
   /* Get the PropertyDescriptor for the DataColumn of the new
 column.
      The column should contain a Boolean value. */
   PropertyDescriptor^ pd = myCurrencyManager->GetItemProperties()[ "Discontinued"
 ];
   DataGridColumnStyle^ myColumn = gcnew System::Windows::Forms::DataGridBoolColumn(
 pd );
   myColumn->MappingName = "Discontinued";
   myGridColumnCol->Add( myColumn );
}

private void CreateNewDataGridColumn()
{
    System.Windows.Forms.GridColumnStylesCollection myGridColumnCol;
    myGridColumnCol = dataGrid1.get_TableStyles().
        get_Item(0).get_GridColumnStyles();
    // Get the CurrencyManager for the table.
    CurrencyManager myCurrencyManager = 
        (CurrencyManager)(this.get_BindingContext().
        get_Item(ds.get_Tables().get_Item("Products")));
    /*  Get the PropertyDescriptor for the DataColumn of the new
 column.
        The column should contain a Boolean value. 
     */
    PropertyDescriptor pd = myCurrencyManager.GetItemProperties().
        get_Item("Discontinued");
    DataGridColumnStyle myColumn = 
        new System.Windows.Forms.DataGridBoolColumn(pd);     
   
    myColumn.set_MappingName("Discontinued");
    myGridColumnCol.Add(myColumn);
} //CreateNewDataGridColumn
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridBoolColumn クラス
DataGridBoolColumn メンバ
System.Windows.Forms 名前空間
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
DataColumn

DataGridBoolColumn コンストラクタ

DataGridBoolColumn クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
DataGridBoolColumn () DataGridBoolColumn クラスの新しいインスタンスを初期化します。
DataGridBoolColumn (PropertyDescriptor) PropertyDescriptor を指定して、DataGridBoolColumn の新しいインスタンスを初期化します。
DataGridBoolColumn (PropertyDescriptor, Boolean) 指定した PropertyDescriptor を使用して DataGridBoolColumn の新しいインスタンスを初期化し、列スタイルを既定の列とするかどうかを指定します。
参照参照

関連項目

DataGridBoolColumn クラス
DataGridBoolColumn メンバ
System.Windows.Forms 名前空間
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
DataColumn

DataGridBoolColumn コンストラクタ (PropertyDescriptor, Boolean)

指定した PropertyDescriptor を使用して DataGridBoolColumn の新しいインスタンスを初期化し、列スタイルを既定の列とするかどうかを指定します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim prop As PropertyDescriptor
Dim isDefault As Boolean

Dim instance As New DataGridBoolColumn(prop,
 isDefault)
public DataGridBoolColumn (
    PropertyDescriptor prop,
    bool isDefault
)
public:
DataGridBoolColumn (
    PropertyDescriptor^ prop, 
    bool isDefault
)
public DataGridBoolColumn (
    PropertyDescriptor prop, 
    boolean isDefault
)
public function DataGridBoolColumn (
    prop : PropertyDescriptor, 
    isDefault : boolean
)

パラメータ

prop

列に関連付けられている PropertyDescriptor。

isDefault

既定の列として設定する場合は true。それ以外の場合は false。

解説解説

PropertyDescriptor を取得するには、最初に BindingContext を使用して適切な BindingManagerBase を返します。その後、BindingManagerBase の GetItemProperties メソッドを使用して、PropertyDescriptorCollection を返します。最後に、PropertyDescriptorCollection の Item プロパティを使用して、列に特有の PropertyDescriptor を返します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataGridBoolColumn プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ Alignment  列内のテキストの配置について値を取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ AllowNull null 値を使用できるかどうかを示す値を取得または設定します。
パブリック プロパティ Container  Component を格納している IContainer を取得します。 ( Component から継承されます。)
パブリック プロパティ DataGridTableStyle  列の DataGridTableStyle を取得します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ FalseValue 列の値を false に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ HeaderAccessibleObject  列の AccessibleObject を取得します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ HeaderText  列ヘッダーのテキストを取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ MappingName  列スタイルの割り当て先のデータ メンバの名前を取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ NullText  列が null 参照 (Visual Basic では Nothing) を格納している場合に表示されるテキストを取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ NullValue 列の値を Value に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ PropertyDescriptor  DataGridColumnStyle によって表示されたデータの属性を判断する PropertyDescriptor を取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ ReadOnly  列のデータを編集できるかどうかを示す値を取得または設定します。 ( DataGridColumnStyle から継承されます。)
パブリック プロパティ Site  Component の ISite を取得または設定します。 ( Component から継承されます。)
パブリック プロパティ TrueValue 列の値を true に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ Width  列の幅を取得または設定します。 ( DataGridColumnStyle から継承されます。)
プロテクト プロパティプロテクト プロパティ
参照参照

関連項目

DataGridBoolColumn クラス
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
GetType
Type

DataGridBoolColumn メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  オーバーロードされます。 Component によって使用されているリソースを解放します。 ( Component から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ResetHeaderText  HeaderText を既定値 null 参照 (Visual Basic では Nothing) にリセットします。 ( DataGridColumnStyle から継承されます。)
パブリック メソッド ToString  Component の名前を格納している String を返します (存在する場合)。このメソッドはオーバーライドできません。 ( Component から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド Abort オーバーライドされます。 編集プロシージャを中断する要求を実行します。
プロテクト メソッド BeginUpdate  EndUpdate メソッドが呼び出されるまで、列の描画を中断します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド CheckValidDataSource  System.Windows.Forms.DataGrid が有効なデータ ソースを保持していない場合、またはこの列がデータ ソースの有効なプロパティに割り当てられていない場合は、例外がスローされます。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド ColumnStartedEditing  ユーザーが列の編集を開始したことを System.Windows.Forms.DataGrid に通知します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド Commit オーバーライドされます。 編集プロシージャを完了する要求を実行します。
プロテクト メソッド ConcedeFocus オーバーライドされます。  
プロテクト メソッド CreateHeaderAccessibleObject  列の AccessibleObject を取得します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド Dispose  オーバーロードされます。 Component によって使用されているリソースを解放します。 ( Component から継承されます。)
プロテクト メソッド Edit オーバーロードされます。 値を編集するためにセルを準備します。
プロテクト メソッド EndUpdate  BeginUpdate メソッドを呼び出して中断されていた列の描画を再開します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド EnterNullValue オーバーライドされます。 Value を列に入力します。
プロテクト メソッド Finalize  Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 ( Component から継承されます。)
プロテクト メソッド GetColumnValueAtRow オーバーライドされます。 指定した行の値を取得します。
プロテクト メソッド GetMinimumHeight オーバーライドされます。 列のセルの高さを取得します。
プロテクト メソッド GetPreferredHeight オーバーライドされます。 列のサイズを変更する際に使用される高さを取得します。
プロテクト メソッド GetPreferredSize オーバーライドされます。 特定の値を格納するように指定したセルの最適な幅と高さを取得します。
プロテクト メソッド GetService  Component またはその Container で提供されるサービスを表すオブジェクトを返します。 ( Component から継承されます。)
プロテクト メソッド Invalidate  列を再描画し、描画メッセージがコントロールに送信されます。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド MemberwiseClone  オーバーロードされます。 ( MarshalByRefObject から継承されます。)
プロテクト メソッド Paint オーバーロードされます。 オーバーライドされます。 列を描画します。
プロテクト メソッド ReleaseHostedControl  列がホストするコントロールが不要な場合に、その列がリソースを解放できるようにします。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド SetColumnValueAtRow オーバーライドされます。 指定した行に値を設定します。
プロテクト メソッド SetDataGrid  この列が属する System.Windows.Forms.DataGrid コントロールを設定します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド SetDataGridInColumn  列の System.Windows.Forms.DataGrid を設定します。 ( DataGridColumnStyle から継承されます。)
プロテクト メソッド UpdateUI  指定されたテキストを使用して、指定した行の値を更新します。 ( DataGridColumnStyle から継承されます。)
参照参照

関連項目

DataGridBoolColumn クラス
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
GetType
Type

DataGridBoolColumn メンバ

各セルで Boolean 値を表すためのチェック ボックスを格納する列を指定します。

DataGridBoolColumn データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridBoolColumn オーバーロードされます。 DataGridBoolColumn クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ Alignment  列内のテキストの配置について値を取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ AllowNull null 値を使用できるかどうかを示す値を取得または設定します。
パブリック プロパティ Container  Component を格納している IContainer を取得します。(Component から継承されます。)
パブリック プロパティ DataGridTableStyle  列の DataGridTableStyle を取得します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ FalseValue 列の値を false に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ HeaderAccessibleObject  列の AccessibleObject を取得します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ HeaderText  列ヘッダーのテキストを取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ MappingName  列スタイルの割り当て先のデータ メンバの名前を取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ NullText  列が null 参照 (Visual Basic では Nothing) を格納している場合に表示されるテキストを取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ NullValue 列の値を Value に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ PropertyDescriptor  DataGridColumnStyle によって表示されたデータの属性を判断する PropertyDescriptor を取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ ReadOnly  列のデータを編集できるかどうかを示す値を取得または設定します。(DataGridColumnStyle から継承されます。)
パブリック プロパティ Site  Component の ISite を取得または設定します。(Component から継承されます。)
パブリック プロパティ TrueValue 列の値を true に設定するときに使用される実際の値を取得または設定します。
パブリック プロパティ Width  列の幅を取得または設定します。(DataGridColumnStyle から継承されます。)
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Dispose  オーバーロードされます。 Component によって使用されているリソースを解放します。 (Component から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ResetHeaderText  HeaderText を既定値 null 参照 (Visual Basic では Nothing) にリセットします。 (DataGridColumnStyle から継承されます。)
パブリック メソッド ToString  Component の名前を格納している String を返します (存在する場合)。このメソッドはオーバーライドできません。 (Component から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド Abort オーバーライドされます。 編集プロシージャを中断する要求を実行します。
プロテクト メソッド BeginUpdate  EndUpdate メソッドが呼び出されるまで、列の描画を中断します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド CheckValidDataSource  System.Windows.Forms.DataGrid が有効なデータ ソースを保持していない場合、またはこの列がデータ ソースの有効なプロパティに割り当てられていない場合は、例外がスローされます。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド ColumnStartedEditing  ユーザーが列の編集を開始したことを System.Windows.Forms.DataGrid に通知します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド Commit オーバーライドされます。 編集プロシージャを完了する要求を実行します。
プロテクト メソッド ConcedeFocus オーバーライドされます。  
プロテクト メソッド CreateHeaderAccessibleObject  列の AccessibleObject を取得します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド Dispose  オーバーロードされます。 Component によって使用されているリソースを解放します。 (Component から継承されます。)
プロテクト メソッド Edit オーバーロードされます。 値を編集するためにセルを準備します。
プロテクト メソッド EndUpdate  BeginUpdate メソッドを呼び出して中断されていた列の描画を再開します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド EnterNullValue オーバーライドされます。 Value を列に入力します。
プロテクト メソッド Finalize  Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 (Component から継承されます。)
プロテクト メソッド GetColumnValueAtRow オーバーライドされます。 指定した行の値を取得します。
プロテクト メソッド GetMinimumHeight オーバーライドされます。 列のセルの高さを取得します。
プロテクト メソッド GetPreferredHeight オーバーライドされます。 列のサイズを変更する際に使用される高さを取得します。
プロテクト メソッド GetPreferredSize オーバーライドされます。 特定の値を格納するように指定したセルの最適な幅と高さを取得します。
プロテクト メソッド GetService  Component またはその Container で提供されるサービスを表すオブジェクトを返します。 (Component から継承されます。)
プロテクト メソッド Invalidate  列を再描画し、描画メッセージがコントロールに送信されます。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド MemberwiseClone  オーバーロードされます。 ( MarshalByRefObject から継承されます。)
プロテクト メソッド Paint オーバーロードされます。 オーバーライドされます。 列を描画します。
プロテクト メソッド ReleaseHostedControl  列がホストするコントロールが不要な場合に、その列がリソースを解放できるようにします。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド SetColumnValueAtRow オーバーライドされます。 指定した行に値を設定します。
プロテクト メソッド SetDataGrid  この列が属する System.Windows.Forms.DataGrid コントロールを設定します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド SetDataGridInColumn  列の System.Windows.Forms.DataGrid を設定します。 (DataGridColumnStyle から継承されます。)
プロテクト メソッド UpdateUI  指定されたテキストを使用して、指定した行の値を更新します。 (DataGridColumnStyle から継承されます。)
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント AlignmentChanged  Alignment プロパティの値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント AllowNullChanged AllowNull プロパティが変更されると発生します。
パブリック イベント Disposed  コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。(Component から継承されます。)
パブリック イベント FalseValueChanged FalseValue プロパティが変更されると発生します。
パブリック イベント FontChanged  列のフォントが変更されたときに発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント HeaderTextChanged  HeaderText プロパティの値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント MappingNameChanged  MappingName の値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント NullTextChanged  NullText の値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント PropertyDescriptorChanged  PropertyDescriptor プロパティの値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント ReadOnlyChanged  ReadOnly プロパティの値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
パブリック イベント TrueValueChanged TrueValue プロパティが変更されると発生します。
パブリック イベント WidthChanged  Width プロパティの値が変更された場合に発生します。(DataGridColumnStyle から継承されます。)
参照参照

関連項目

DataGridBoolColumn クラス
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle
GridColumnStylesCollection
GetType
Type



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataGridBoolColumn」の関連用語

DataGridBoolColumnのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



DataGridBoolColumnのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS