DataGridBoolColumn Classe

Definizione

Specifica una colonna in cui ogni cella contiene una casella di controllo per la rappresentazione di un valore Boolean.Specifies a column in which each cell contains a check box for representing a Boolean value.

public ref class DataGridBoolColumn : System::Windows::Forms::DataGridColumnStyle
public class DataGridBoolColumn : System.Windows.Forms.DataGridColumnStyle
type DataGridBoolColumn = class
    inherit DataGridColumnStyle
Public Class DataGridBoolColumn
Inherits DataGridColumnStyle
Ereditarietà

Esempi

Nell'esempio di codice seguente viene prima creato un nuovo DataGridBoolColumn e lo si aggiunge al GridColumnStylesCollection di un DataGridTableStyle.The following code example first creates a new DataGridBoolColumn and adds it to the GridColumnStylesCollection of a DataGridTableStyle.

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()
{
   Application::Run( gcnew MyForm );
}
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() 
    {
        Application.Run(new MyForm());
    }
}

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);
    }
}
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 (expressionColumn IsNot 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 (col IsNot 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 = (Me.expressionColumn IsNot Nothing) And (Me.expressionColumn.Expression IsNot 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

Commenti

Il DataGridBoolColumn deriva dalla classe abstract DataGridColumnStyle.The DataGridBoolColumn derives from the abstract class DataGridColumnStyle. In fase di esecuzione, il DataGridBoolColumn contiene le caselle di controllo in ogni cella con tre stati per impostazione predefinita: checked (true), dechecked (false) e Value.At run time, the DataGridBoolColumn contains check boxes in each cell that have three states by default: checked (true), unchecked (false), and Value. Per utilizzare le caselle di controllo a due Stati, impostare la proprietà AllowNull su false.To use two-state check boxes, set the AllowNull property to false.

Le proprietà aggiunte alla classe includono FalseValue, NullValuee TrueValue.Properties added to the class include FalseValue, NullValue, and TrueValue. Queste proprietà specificano il valore sottostante ciascuno degli Stati della colonna.These properties specify the value underlying each of the column's states.

Costruttori

DataGridBoolColumn()

Inizializza una nuova istanza della classe DataGridBoolColumn.Initializes a new instance of the DataGridBoolColumn class.

DataGridBoolColumn(PropertyDescriptor)

Inizializza una nuova istanza di un oggetto DataGridBoolColumn con il controllo PropertyDescriptor specificato.Initializes a new instance of a DataGridBoolColumn with the specified PropertyDescriptor.

DataGridBoolColumn(PropertyDescriptor, Boolean)

Inizializza una nuova istanza di una classe DataGridBoolColumn con la classe PropertyDescriptor specificata e indicando se lo stile della colonna è predefinito.Initializes a new instance of a DataGridBoolColumn with the specified PropertyDescriptor, and specifying whether the column style is a default column.

Proprietà

Alignment

Ottiene o imposta l'allineamento del testo in una colonna.Gets or sets the alignment of text in a column.

(Ereditato da DataGridColumnStyle)
AllowNull

Ottiene o imposta un valore che indica se i valori null sono consentiti.Gets or sets a value indicating whether null values are allowed.

CanRaiseEvents

Ottiene un valore che indica se il componente può generare un evento.Gets a value indicating whether the component can raise an event.

(Ereditato da Component)
Container

Ottiene il IContainer che contiene il Component.Gets the IContainer that contains the Component.

(Ereditato da Component)
DataGridTableStyle

Ottiene l'oggetto DataGridTableStyle per la colonna.Gets the DataGridTableStyle for the column.

(Ereditato da DataGridColumnStyle)
DesignMode

Ottiene un valore che indica se il Component si trova in modalità progettazione.Gets a value that indicates whether the Component is currently in design mode.

(Ereditato da Component)
Events

Ottiene l'elenco dei gestori eventi allegati a questo Component.Gets the list of event handlers that are attached to this Component.

(Ereditato da Component)
FalseValue

Ottiene o imposta il valore effettivo utilizzato quando si imposta il valore della colonna su false.Gets or sets the actual value used when setting the value of the column to false.

FontHeight

Ottiene l'altezza del tipo di carattere della colonna.Gets the height of the column's font.

(Ereditato da DataGridColumnStyle)
HeaderAccessibleObject

Ottiene l'oggetto AccessibleObject per la colonna.Gets the AccessibleObject for the column.

(Ereditato da DataGridColumnStyle)
HeaderText

Ottiene o imposta il testo dell'intestazione della colonna.Gets or sets the text of the column header.

(Ereditato da DataGridColumnStyle)
MappingName

Ottiene o imposta il nome del membro dati in base al quale eseguire il mapping dello stile di colonna.Gets or sets the name of the data member to map the column style to.

(Ereditato da DataGridColumnStyle)
NullText

Ottiene o imposta il testo visualizzato quando la colonna contiene un valore null.Gets or sets the text that is displayed when the column contains null.

(Ereditato da DataGridColumnStyle)
NullValue

Ottiene o imposta il valore effettivo utilizzato quando si imposta il valore della colonna su Value.Gets or sets the actual value used when setting the value of the column to Value.

PropertyDescriptor

Ottiene o imposta l'oggetto PropertyDescriptor che determina gli attributi dei dati visualizzati dall'oggetto DataGridColumnStyle.Gets or sets the PropertyDescriptor that determines the attributes of data displayed by the DataGridColumnStyle.

(Ereditato da DataGridColumnStyle)
ReadOnly

Ottiene o imposta un valore che indica se i dati nella colonna possono essere modificati.Gets or sets a value indicating whether the data in the column can be edited.

(Ereditato da DataGridColumnStyle)
Site

Ottiene o imposta l'oggetto ISite dell'oggetto Component.Gets or sets the ISite of the Component.

(Ereditato da Component)
TrueValue

Ottiene o imposta il valore effettivo utilizzato quando si imposta il valore della colonna su true.Gets or sets the actual value used when setting the value of the column to true.

Width

Ottiene o imposta la larghezza della colonna.Gets or sets the width of the column.

(Ereditato da DataGridColumnStyle)

Metodi

Abort(Int32)

Avvia una richiesta di interruzione di una routine di modifica.Initiates a request to interrupt an edit procedure.

BeginUpdate()

Sospende il disegno della colonna fino alla chiamata del metodo EndUpdate().Suspends the painting of the column until the EndUpdate() method is called.

(Ereditato da DataGridColumnStyle)
CheckValidDataSource(CurrencyManager)

Genera un'eccezione se il controllo DataGrid non dispone di un'origine dati valida o se su questa colonna non è stato effettuato il mapping a una proprietà valida nell'origine dati.Throws an exception if the DataGrid does not have a valid data source, or if this column is not mapped to a valid property in the data source.

(Ereditato da DataGridColumnStyle)
ColumnStartedEditing(Control)

Informa l'oggetto DataGrid che l'utente ha iniziato a modificare la colonna.Informs the DataGrid that the user has begun editing the column.

(Ereditato da DataGridColumnStyle)
Commit(CurrencyManager, Int32)

Avvia una richiesta di completamento di una routine di modifica.Initiates a request to complete an editing procedure.

ConcedeFocus()

Notifica a una colonna che deve lasciare l'attivazione al controllo che ospita.Notifies a column that it must relinquish the focus to the control it is hosting.

CreateHeaderAccessibleObject()

Ottiene l'oggetto AccessibleObject per la colonna.Gets the AccessibleObject for the column.

(Ereditato da DataGridColumnStyle)
CreateObjRef(Type)

Consente di creare un oggetto che contiene tutte le informazioni rilevanti necessarie per la generazione del proxy utilizzato per effettuare la comunicazione con un oggetto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Ereditato da MarshalByRefObject)
Dispose()

Rilascia tutte le risorse usate da Component.Releases all resources used by the Component.

(Ereditato da Component)
Dispose(Boolean)

Rilascia le risorse non gestite usate da Component e facoltativamente rilascia le risorse gestite.Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Ereditato da Component)
Edit(CurrencyManager, Int32, Rectangle, Boolean)

Prepara una cella per la modifica.Prepares a cell for editing.

(Ereditato da DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

Prepara la cella per la modifica mediante i parametri dell'oggetto CurrencyManager, del numero di riga e dell'oggetto Rectangle specificati.Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.

(Ereditato da DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

Prepara la cella per la modifica di un valore.Prepares the cell for editing a value.

EndUpdate()

Riprende il disegno delle colonne sospeso chiamando il metodo BeginUpdate().Resumes the painting of columns suspended by calling the BeginUpdate() method.

(Ereditato da DataGridColumnStyle)
EnterNullValue()

Immette un valore Value nella colonna.Enters a Value into the column.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Ereditato da Object)
GetColumnValueAtRow(CurrencyManager, Int32)

Ottiene il valore in corrispondenza della riga specificata.Gets the value at the specified row.

GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Ereditato da Object)
GetLifetimeService()

Consente di recuperare l'oggetto servizio di durata corrente per controllare i criteri di durata per l'istanza.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Ereditato da MarshalByRefObject)
GetMinimumHeight()

Ottiene l'altezza di una cella in una colonna.Gets the height of a cell in a column.

GetPreferredHeight(Graphics, Object)

Ottiene l'altezza utilizzata quando si ridimensionano le colonne.Gets the height used when resizing columns.

GetPreferredSize(Graphics, Object)

Ottiene la larghezza e l'altezza ottimali di una cella che dovrà contenere un valore specifico dato.Gets the optimum width and height of a cell given a specific value to contain.

GetService(Type)

Consente di restituire un oggetto che rappresenta un servizio fornito da Component o dal relativo Container.Returns an object that represents a service provided by the Component or by its Container.

(Ereditato da Component)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Ereditato da Object)
InitializeLifetimeService()

Ottiene un oggetto servizio di durata per controllare i criteri di durata per questa istanza.Obtains a lifetime service object to control the lifetime policy for this instance.

(Ereditato da MarshalByRefObject)
Invalidate()

Ridisegna la colonna e fa sì che venga inviato un messaggio di disegno al controllo.Redraws the column and causes a paint message to be sent to the control.

(Ereditato da DataGridColumnStyle)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Ereditato da Object)
MemberwiseClone(Boolean)

Crea una copia dei riferimenti dell'oggetto MarshalByRefObject corrente.Creates a shallow copy of the current MarshalByRefObject object.

(Ereditato da MarshalByRefObject)
Paint(Graphics, Rectangle, CurrencyManager, Int32)

Crea la classe DataGridBoolColumn con la classe Graphics, la struttura Rectangle e il numero di righe specificati.Draws the DataGridBoolColumn with the given Graphics, Rectangle and row number.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Boolean)

Crea la classe DataGridBoolColumn con la classe Graphics, la struttura Rectangle, il numero di righe e le impostazioni di allineamento specificati.Draws the DataGridBoolColumn with the given Graphics, Rectangle, row number, and alignment settings.

Paint(Graphics, Rectangle, CurrencyManager, Int32, Brush, Brush, Boolean)

Crea la classe DataGridBoolColumn con la classe Graphics, la struttura Rectangle, il numero di righe, la classe Brush e la struttura Color specificati.Draws the DataGridBoolColumn with the given Graphics, Rectangle, row number, Brush, and Color.

ReleaseHostedControl()

Consente la liberazione di risorse della colonna quando il controllo in essa contenuto non è più necessario.Allows the column to free resources when the control it hosts is not needed.

(Ereditato da DataGridColumnStyle)
ResetHeaderText()

Reimposta la proprietà HeaderText sul valore predefinito null.Resets the HeaderText to its default value, null.

(Ereditato da DataGridColumnStyle)
SetColumnValueAtRow(CurrencyManager, Int32, Object)

Imposta il valore di una riga specificata.Sets the value of a specified row.

SetDataGrid(DataGrid)

Imposta il controllo DataGrid a cui appartiene la colonna.Sets the DataGrid control that this column belongs to.

(Ereditato da DataGridColumnStyle)
SetDataGridInColumn(DataGrid)

Imposta il controllo DataGrid per la colonna.Sets the DataGrid for the column.

(Ereditato da DataGridColumnStyle)
ToString()

Restituisce un oggetto String che contiene il nome dell'eventuale oggetto Component.Returns a String containing the name of the Component, if any. Questo metodo non deve essere sottoposto a override.This method should not be overridden.

(Ereditato da Component)
UpdateUI(CurrencyManager, Int32, String)

Aggiorna il valore di una riga specificata con il testo dato.Updates the value of a specified row with the given text.

(Ereditato da DataGridColumnStyle)

Eventi

AlignmentChanged

Si verifica quando il valore della proprietà Alignment cambia.Occurs when the Alignment property value changes.

(Ereditato da DataGridColumnStyle)
AllowNullChanged

Si verifica quando si modifica la proprietà AllowNull.Occurs when the AllowNull property is changed.

Disposed

Si verifica quando il componente viene eliminato da una chiamata al metodo Dispose().Occurs when the component is disposed by a call to the Dispose() method.

(Ereditato da Component)
FalseValueChanged

Si verifica quando si modifica la proprietà FalseValue.Occurs when the FalseValue property is changed.

FontChanged

Si verifica quando il tipo di carattere della colonna cambia.Occurs when the column's font changes.

(Ereditato da DataGridColumnStyle)
HeaderTextChanged

Si verifica quando il valore della proprietà HeaderText cambia.Occurs when the HeaderText property value changes.

(Ereditato da DataGridColumnStyle)
MappingNameChanged

Si verifica quando il valore dell'oggetto MappingName cambia.Occurs when the MappingName value changes.

(Ereditato da DataGridColumnStyle)
NullTextChanged

Si verifica quando il valore dell'oggetto NullText cambia.Occurs when the NullText value changes.

(Ereditato da DataGridColumnStyle)
PropertyDescriptorChanged

Si verifica quando il valore della proprietà PropertyDescriptor cambia.Occurs when the PropertyDescriptor property value changes.

(Ereditato da DataGridColumnStyle)
ReadOnlyChanged

Si verifica quando il valore della proprietà ReadOnly cambia.Occurs when the ReadOnly property value changes.

(Ereditato da DataGridColumnStyle)
TrueValueChanged

Viene generato quando si modifica la proprietà TrueValue.Occurs when the TrueValue property value is changed.

WidthChanged

Si verifica quando il valore della proprietà Width cambia.Occurs when the Width property value changes.

(Ereditato da DataGridColumnStyle)

Implementazioni dell'interfaccia esplicita

IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control)

Informa il controllo DataGrid che l'utente ha iniziato a modificare la colonna.Informs the DataGrid control that the user has begun editing the column.

(Ereditato da DataGridColumnStyle)

Si applica a

Vedi anche