DataGridTextBoxColumn Classe

Definição

Hospeda um controle TextBox em uma célula de um DataGridColumnStyle para edição de cadeias de caracteres.Hosts a TextBox control in a cell of a DataGridColumnStyle for editing strings.

public ref class DataGridTextBoxColumn : System::Windows::Forms::DataGridColumnStyle
public class DataGridTextBoxColumn : System.Windows.Forms.DataGridColumnStyle
type DataGridTextBoxColumn = class
    inherit DataGridColumnStyle
Public Class DataGridTextBoxColumn
Inherits DataGridColumnStyle
Herança

Exemplos

O exemplo a seguir cria um DataGridTextBoxColumn e o adiciona ao GridColumnStylesCollection de um DataGrid .The following example creates a DataGridTextBoxColumn and adds it to the GridColumnStylesCollection of a DataGrid. Para executar este exemplo de código, Cole-o em um formulário que tenha um DataGrid nome dataGrid1 e chame-o do construtor do Form .To run this code example, paste it into a form that has a DataGrid named dataGrid1 and call it from the constructor of the Form.

private:
   void AddColumn()
   {
      DataTable^ myTable = gcnew DataTable;
      
      // Add a new DataColumn to the DataTable.
      DataColumn^ myColumn = gcnew DataColumn( "myTextBoxColumn" );
      myColumn->DataType = System::Type::GetType( "System::String" );
      myColumn->DefaultValue = "default string";
      myTable->Columns->Add( myColumn );
      
      // Get the CurrencyManager for the DataTable.
      CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
      
      // Use the CurrencyManager to get the PropertyDescriptor for the new column.
      System::ComponentModel::PropertyDescriptor^ pd = cm->GetItemProperties()[ "myTextBoxColumn" ];
      DataGridTextBoxColumn^ myColumnTextColumn;
      
      // Create the DataGridTextBoxColumn with the PropertyDescriptor.
      myColumnTextColumn = gcnew DataGridTextBoxColumn( pd );
      
      // Add the new DataGridColumn to the GridColumnsCollection.
      dataGrid1->DataSource = myTable;
      dataGrid1->TableStyles->Add( gcnew DataGridTableStyle );
      dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumnTextColumn );
   }

private void AddColumn()
{
     DataTable myTable= new DataTable();
 
     // Add a new DataColumn to the DataTable.
     DataColumn myColumn = new DataColumn("myTextBoxColumn");
     myColumn.DataType = System.Type.GetType("System.String");
     myColumn.DefaultValue="default string";
     myTable.Columns.Add(myColumn);
     // Get the CurrencyManager for the DataTable.
     CurrencyManager cm = (CurrencyManager)this.BindingContext[myTable];
     // Use the CurrencyManager to get the PropertyDescriptor for the new column.
     PropertyDescriptor pd = cm.GetItemProperties()["myTextBoxColumn"];
     DataGridTextBoxColumn myColumnTextColumn;
     // Create the DataGridTextBoxColumn with the PropertyDescriptor.
     myColumnTextColumn = new DataGridTextBoxColumn(pd);
     // Add the new DataGridColumn to the GridColumnsCollection.
     dataGrid1.DataSource= myTable;
     dataGrid1.TableStyles.Add(new DataGridTableStyle());
     dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumnTextColumn);
 }

Private Sub AddColumn()
    Dim myTable As New DataTable()
    
    ' Add a new DataColumn to the DataTable.
    Dim myColumn As New DataColumn("myTextBoxColumn")
    myColumn.DataType = System.Type.GetType("System.String")
    myColumn.DefaultValue = "default string"
    myTable.Columns.Add(myColumn)
    ' Get the CurrencyManager for the DataTable.
    Dim cm As CurrencyManager = CType(Me.BindingContext(myTable), CurrencyManager)
    ' Use the CurrencyManager to get the PropertyDescriptor for the new column.
    Dim pd As PropertyDescriptor = cm.GetItemProperties()("myTextBoxColumn")
    Dim myColumnTextColumn As DataGridTextBoxColumn
    ' Create the DataGridTextBoxColumn with the PropertyDescriptor.
    myColumnTextColumn = New DataGridTextBoxColumn(pd)
    ' Add the new DataGridColumn to the GridColumnsCollection.
    dataGrid1.DataSource = myTable
    dataGrid1.TableStyles.Add(New DataGridTableStyle())
    dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumnTextColumn)
End Sub

Comentários

A DataGridTextBoxColumn classe deriva da abstract classe DataGridColumnStyle .The DataGridTextBoxColumn class derives from the abstract class DataGridColumnStyle. Em tempo de execução, o DataGridTextBoxColumn hospeda um DataGridTextBox controle que permite aos usuários editar texto.At run time, the DataGridTextBoxColumn hosts a DataGridTextBox control that allows users to edit text.

As propriedades especiais adicionadas à classe incluem Format e HideEditBox .Special properties added to the class include Format, and HideEditBox. Essas propriedades permitem que você acesse o DataGridTextBox controle hospedado e seus atributos e defina o formato para exibir valores.These properties allow you to access the hosted DataGridTextBox control and its attributes, and set the format for displaying values.

Se a fonte de dados for DataTable um DataColumn objeto que contém, a DataType propriedade de DataColumn deverá ser definida como um tipo de dados que pode ser editado logicamente em um controle de caixa de texto.If the data source is a DataTable containing DataColumn objects, the DataType property of the DataColumn should be set to a data type that can logically be edited in a text box control. Os seguintes tipos de dados são associados automaticamente a DataGridTextBoxColumn : Byte , DateTime , Decimal , Double , Int16 , Int32 , Int64 , UInt16 , UInt32 , UInt64 , Single e String .The following data types are automatically associated with a DataGridTextBoxColumn : Byte, DateTime, Decimal, Double, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, and String.

Observação

Os seguintes tipos não têm suporte total do Visual Basic: DateTime ,,, UInt16 UInt32 UInt64 e TimeSpan .The following types are not fully supported by Visual Basic: DateTime, UInt16, UInt32, UInt64, and TimeSpan. (Operadores não são permitidos.)(Operators are not allowed.)

Construtores

DataGridTextBoxColumn()

Inicializa uma nova instância da classe DataGridTextBoxColumn.Initializes a new instance of the DataGridTextBoxColumn class.

DataGridTextBoxColumn(PropertyDescriptor)

Inicializa uma nova instância de um DataGridTextBoxColumn com um PropertyDescriptorespecificado.Initializes a new instance of a DataGridTextBoxColumn with a specified PropertyDescriptor.

DataGridTextBoxColumn(PropertyDescriptor, Boolean)

Inicializa uma nova instância da classe DataGridTextBoxColumn usando o PropertyDescriptor especificado.Initializes a new instance of the DataGridTextBoxColumn class using the specified PropertyDescriptor. Especifica se o DataGridTextBoxColumn é uma coluna padrão.Specifies whether the DataGridTextBoxColumn is a default column.

DataGridTextBoxColumn(PropertyDescriptor, String)

Inicializa uma nova instância de um DataGridTextBoxColumn com o PropertyDescriptor e o formato especificados.Initializes a new instance of a DataGridTextBoxColumn with the specified PropertyDescriptor and format.

DataGridTextBoxColumn(PropertyDescriptor, String, Boolean)

Inicializa uma nova instância da classe DataGridTextBoxColumn com um PropertyDescriptor e formato especificados.Initializes a new instance of the DataGridTextBoxColumn class with a specified PropertyDescriptor and format. Especifica se a coluna é a coluna padrão.Specifies whether the column is the default column.

Propriedades

Alignment

Obtém ou define o alinhamento do texto em uma coluna.Gets or sets the alignment of text in a column.

(Herdado de DataGridColumnStyle)
CanRaiseEvents

Obtém um valor que indica se o componente pode acionar um evento.Gets a value indicating whether the component can raise an event.

(Herdado de Component)
Container

Obtém o IContainer que contém o Component.Gets the IContainer that contains the Component.

(Herdado de Component)
DataGridTableStyle

Obtém o DataGridTableStyle da coluna.Gets the DataGridTableStyle for the column.

(Herdado de DataGridColumnStyle)
DesignMode

Obtém um valor que indica se o Component está no modo de design no momento.Gets a value that indicates whether the Component is currently in design mode.

(Herdado de Component)
Events

Obtém a lista de manipuladores de eventos que estão anexados a este Component.Gets the list of event handlers that are attached to this Component.

(Herdado de Component)
FontHeight

Obtém a altura da fonte da coluna.Gets the height of the column's font.

(Herdado de DataGridColumnStyle)
Format

Obtém ou define os caracteres que especificam como o texto é formatado.Gets or sets the character(s) that specify how text is formatted.

FormatInfo

Obtém ou define as informações específicas da cultura usadas para determinar como os valores são formatados.Gets or sets the culture specific information used to determine how values are formatted.

HeaderAccessibleObject

Obtém o AccessibleObject da coluna.Gets the AccessibleObject for the column.

(Herdado de DataGridColumnStyle)
HeaderText

Obtém ou define o contexto do cabeçalho da coluna.Gets or sets the text of the column header.

(Herdado de DataGridColumnStyle)
MappingName

Obtém ou define o nome do membro de dados para o qual mapear o estilo da coluna.Gets or sets the name of the data member to map the column style to.

(Herdado de DataGridColumnStyle)
NullText

Obtém ou define o texto que é exibido quando a coluna contém null.Gets or sets the text that is displayed when the column contains null.

(Herdado de DataGridColumnStyle)
PropertyDescriptor

Obtém ou define o PropertyDescriptor do DataGridTextBoxColumn.Gets or sets the PropertyDescriptor for the DataGridTextBoxColumn.

ReadOnly

Define um valor que indica se a coluna da caixa de texto é somente leitura.Sets a value indicating whether the text box column is read-only.

Site

Obtém ou define o ISite do Component.Gets or sets the ISite of the Component.

(Herdado de Component)
TextBox

Obtém o controle TextBox hospedado.Gets the hosted TextBox control.

Width

Obtém ou define a largura da coluna.Gets or sets the width of the column.

(Herdado de DataGridColumnStyle)

Métodos

Abort(Int32)

Inicia uma solicitação para interromper um procedimento de edição.Initiates a request to interrupt an edit procedure.

BeginUpdate()

Suspende a pintura da coluna até que o método EndUpdate() seja chamado.Suspends the painting of the column until the EndUpdate() method is called.

(Herdado de DataGridColumnStyle)
CheckValidDataSource(CurrencyManager)

Gera uma exceção se o DataGrid não tem uma fonte de dados válido ou se essa coluna não está mapeada para uma propriedade válida na fonte de dados.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.

(Herdado de DataGridColumnStyle)
ColumnStartedEditing(Control)

Informa ao DataGrid que o usuário começou a editar a coluna.Informs the DataGrid that the user has begun editing the column.

(Herdado de DataGridColumnStyle)
Commit(CurrencyManager, Int32)

Inicia uma solicitação para concluir um procedimento de edição.Initiates a request to complete an editing procedure.

ConcedeFocus()

Informa a coluna de que o foco está sendo concedido.Informs the column that the focus is being conceded.

CreateHeaderAccessibleObject()

Obtém o AccessibleObject da coluna.Gets the AccessibleObject for the column.

(Herdado de DataGridColumnStyle)
CreateObjRef(Type)

Cria um objeto que contém todas as informações relevantes necessárias para gerar um proxy usado para se comunicar com um objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Herdado de MarshalByRefObject)
Dispose()

Libera todos os recursos usados pelo Component.Releases all resources used by the Component.

(Herdado de Component)
Dispose(Boolean)

Libera os recursos não gerenciados usados pelo Component e opcionalmente libera os recursos gerenciados.Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Herdado de Component)
Edit(CurrencyManager, Int32, Rectangle, Boolean)

Prepara uma célula para edição.Prepares a cell for editing.

(Herdado de DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String)

Prepara a célula para edição usando o CurrencyManager, o número da linha e os parâmetros Rectangle especificados.Prepares the cell for editing using the specified CurrencyManager, row number, and Rectangle parameters.

(Herdado de DataGridColumnStyle)
Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean)

Prepara uma célula para edição.Prepares a cell for editing.

EndEdit()

Encerra a operação de edição no DataGridColumnStyle.Ends an edit operation on the DataGridColumnStyle.

EndUpdate()

Retoma a pintura de colunas suspensa chamando o método BeginUpdate().Resumes the painting of columns suspended by calling the BeginUpdate() method.

(Herdado de DataGridColumnStyle)
EnterNullValue()

Insere um Value na coluna.Enters a Value in the column.

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetColumnValueAtRow(CurrencyManager, Int32)

Obtém o valor na linha especificada do CurrencyManager especificado.Gets the value in the specified row from the specified CurrencyManager.

(Herdado de DataGridColumnStyle)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetLifetimeService()
Obsoleto.

Recupera o objeto de serviço de tempo de vida atual que controla a política de ciclo de vida para esta instância.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Herdado de MarshalByRefObject)
GetMinimumHeight()

Obtém a altura de uma célula em um DataGridColumnStyle.Gets the height of a cell in a DataGridColumnStyle.

GetPreferredHeight(Graphics, Object)

Obtém a altura a ser usada para redimensionar automaticamente as colunas.Gets the height to be used in for automatically resizing columns.

GetPreferredSize(Graphics, Object)

Retorna a largura e a altura ideal da célula em uma linha especificada em relação ao valor indicado.Returns the optimum width and height of the cell in a specified row relative to the specified value.

GetService(Type)

Retorna um objeto que representa um serviço fornecido pelo Component ou pelo seu Container.Returns an object that represents a service provided by the Component or by its Container.

(Herdado de Component)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
HideEditBox()

Oculta o controle DataGridTextBox e move o foco para o controle DataGrid.Hides the DataGridTextBox control and moves the focus to the DataGrid control.

InitializeLifetimeService()
Obsoleto.

Obtém um objeto de serviço de tempo de vida para controlar a política de tempo de vida para essa instância.Obtains a lifetime service object to control the lifetime policy for this instance.

(Herdado de MarshalByRefObject)
Invalidate()

Redesenha a coluna e faz com que uma mensagem de pintura seja enviada para o controle.Redraws the column and causes a paint message to be sent to the control.

(Herdado de DataGridColumnStyle)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
MemberwiseClone(Boolean)

Cria uma cópia superficial do objeto MarshalByRefObject atual.Creates a shallow copy of the current MarshalByRefObject object.

(Herdado de MarshalByRefObject)
Paint(Graphics, Rectangle, CurrencyManager, Int32)

Pinta o DataGridColumnStyle com o Graphics, Rectangle, CurrencyManager e o número de linha especificados.Paints the a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, and row number.

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

Pinta um DataGridColumnStyle com o Graphics, Rectangle, CurrencyManager, número de linha e alinhamento especificados.Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, and alignment.

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

Pinta um DataGridColumnStyle com o Graphics, Rectangle, CurrencyManager, número de linha, Brush e cor de primeiro plano especificados.Paints a DataGridColumnStyle with the specified Graphics, Rectangle, CurrencyManager, row number, Brush, and foreground color.

PaintText(Graphics, Rectangle, String, Boolean)

Desenha o texto e o retângulo no local fornecido com o alinhamento especificado.Draws the text and rectangle at the given location with the specified alignment.

PaintText(Graphics, Rectangle, String, Brush, Brush, Boolean)

Desenha o texto e o retângulo no local especificado com as cores e o alinhamento indicados.Draws the text and rectangle at the specified location with the specified colors and alignment.

ReleaseHostedControl()

Remove a referência que o DataGrid mantém no controle usado para editar os dados.Removes the reference that the DataGrid holds to the control used to edit data.

ResetHeaderText()

Redefine o HeaderText para seu valor padrão, null.Resets the HeaderText to its default value, null.

(Herdado de DataGridColumnStyle)
SetColumnValueAtRow(CurrencyManager, Int32, Object)

Define o valor em uma linha especificada com o valor de um CurrencyManager especificado.Sets the value in a specified row with the value from a specified CurrencyManager.

(Herdado de DataGridColumnStyle)
SetDataGrid(DataGrid)

Define o controle DataGrid ao qual esta coluna pertence.Sets the DataGrid control that this column belongs to.

(Herdado de DataGridColumnStyle)
SetDataGridInColumn(DataGrid)

Adiciona um controle TextBox ao Control.ControlCollection do controle DataGrid.Adds a TextBox control to the DataGrid control's Control.ControlCollection.

ToString()

Retorna um String que contém o nome do Component, se houver.Returns a String containing the name of the Component, if any. Esse método não deve ser substituído.This method should not be overridden.

(Herdado de Component)
UpdateUI(CurrencyManager, Int32, String)

Atualiza a interface do usuário.Updates the user interface.

Eventos

AlignmentChanged

Ocorre quando o valor da propriedade Alignment muda.Occurs when the Alignment property value changes.

(Herdado de DataGridColumnStyle)
Disposed

Ocorre quando o componente é disposto por uma chamada ao método Dispose().Occurs when the component is disposed by a call to the Dispose() method.

(Herdado de Component)
FontChanged

Ocorre quando a fonte da coluna é alterada.Occurs when the column's font changes.

(Herdado de DataGridColumnStyle)
HeaderTextChanged

Ocorre quando o valor da propriedade HeaderText muda.Occurs when the HeaderText property value changes.

(Herdado de DataGridColumnStyle)
MappingNameChanged

Ocorre quando o valor MappingName é alterado.Occurs when the MappingName value changes.

(Herdado de DataGridColumnStyle)
NullTextChanged

Ocorre quando o valor NullText é alterado.Occurs when the NullText value changes.

(Herdado de DataGridColumnStyle)
PropertyDescriptorChanged

Ocorre quando o valor da propriedade PropertyDescriptor muda.Occurs when the PropertyDescriptor property value changes.

(Herdado de DataGridColumnStyle)
ReadOnlyChanged

Ocorre quando o valor da propriedade ReadOnly muda.Occurs when the ReadOnly property value changes.

(Herdado de DataGridColumnStyle)
WidthChanged

Ocorre quando o valor da propriedade Width muda.Occurs when the Width property value changes.

(Herdado de DataGridColumnStyle)

Implantações explícitas de interface

IDataGridColumnStyleEditingNotificationService.ColumnStartedEditing(Control)

Informa ao controle DataGrid que o usuário começou a editar a coluna.Informs the DataGrid control that the user has begun editing the column.

(Herdado de DataGridColumnStyle)

Aplica-se a

Confira também