DataGridTextBoxColumn コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
使用例
DataGridTextBoxColumn を作成し、GridColumnStylesCollection コレクションに追加する例を次に示します。
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 'AddColumn
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: 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.set_DataType(System.Type.GetType("System.String")); myColumn.set_DefaultValue("default string"); myTable.get_Columns().Add(myColumn); // Get the CurrencyManager for the DataTable. CurrencyManager cm = (CurrencyManager)(this.get_BindingContext(). get_Item(myTable)); // Use the CurrencyManager to get the PropertyDescriptor // for the new column. PropertyDescriptor pd = cm.GetItemProperties(). get_Item("myTextBoxColumn"); DataGridTextBoxColumn myColumnTextColumn; // Create the DataGridTextBoxColumn with the PropertyDescriptor. myColumnTextColumn = new DataGridTextBoxColumn(pd); // Add the new DataGridColumn to the GridColumnsCollection. dataGrid1.set_DataSource(myTable); dataGrid1.get_TableStyles().Add(new DataGridTableStyle()); dataGrid1.get_TableStyles().get_Item(0). get_GridColumnStyles().Add(myColumnTextColumn); } //AddColumn
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
DataGridTextBoxColumn コンストラクタ (PropertyDescriptor, Boolean)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
Dim prop As PropertyDescriptor Dim isDefault As Boolean Dim instance As New DataGridTextBoxColumn(prop, isDefault)
DataGridColumnStyle は、列に表示されるデータの型を決定するために PropertyDescriptor を使用します。PropertyDescriptorCollection を返すには、BindingManagerBase クラスの GetItemProperties メソッドを使用します。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
DataGridTextBoxColumn コンストラクタ (PropertyDescriptor, String, Boolean)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
Dim prop As PropertyDescriptor Dim format As String Dim isDefault As Boolean Dim instance As New DataGridTextBoxColumn(prop, format, isDefault)
public function DataGridTextBoxColumn ( prop : PropertyDescriptor, format : String, isDefault : boolean )
DataGridColumnStyle は、列に表示されるデータの型を決定するために PropertyDescriptor を使用します。PropertyDescriptorCollection を返すには、BindingManagerBase クラスの GetItemProperties メソッドを使用します。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
DataGridTextBoxColumn コンストラクタ (PropertyDescriptor)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
解説
DataGridColumnStyle は、列に表示されるデータの型を決定するために PropertyDescriptor を使用します。PropertyDescriptorCollection を返すには、BindingManagerBase クラスの GetItemProperties メソッドを使用します。
DataGridTextBoxColumn を作成し、GridColumnStylesCollection コレクションに追加する例を次に示します。
Private Sub AddColumn(myTable As DataTable) ' Add a new DataColumn to the DataTable. Dim myColumn As New DataColumn("myTextBoxColumn") myColumn.DataType = GetType(String) myColumn.DefaultValue = "default string" myTable.Columns.Add(myColumn) ' Get the ListManager for the DataTable. Dim cm As CurrencyManager = CType(Me.BindingContext(myTable), CurrencyManager) ' Use the ListManager to get the PropertyDescriptor for the new column. Dim pd As PropertyDescriptor = cm.GetItemProperties()("myTextBoxColumn") ' Create a new DataTimeFormat object. Dim fmt As New DateTimeFormatInfo() ' Insert code to set format. Dim myColumnTextColumn As DataGridTextBoxColumn ' Create the DataGridTextBoxColumn with the PropertyDescriptor and Format. myColumnTextColumn = New DataGridTextBoxColumn(pd, fmt.SortableDateTimePattern) ' Add the new DataGridColumnStyle to the GridColumnsCollection. dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumnTextColumn) End Sub 'AddColumn
private void AddColumn(DataTable myTable){ // Add a new DataColumn to the DataTable. DataColumn myColumn = new DataColumn("myTextBoxColumn"); myColumn.DataType = typeof(String); myColumn.DefaultValue="default string"; myTable.Columns.Add(myColumn); // Get the ListManager for the DataTable. CurrencyManager cm = (CurrencyManager)this.BindingContext[myTable]; // Use the ListManager to get the PropertyDescriptor for the new column. PropertyDescriptor pd = cm.GetItemProperties()["myTextBoxColumn"]; // Create a new DataTimeFormat object. DateTimeFormatInfo fmt = new DateTimeFormatInfo(); // Insert code to set format. DataGridTextBoxColumn myColumnTextColumn; // Create the DataGridTextBoxColumn with the PropertyDescriptor and Format. myColumnTextColumn = new DataGridTextBoxColumn(pd, fmt.SortableDateTimePattern); // Add the new DataGridColumnStyle to the GridColumnsCollection. dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumnTextColumn); }
private: void AddColumn( DataTable^ myTable ) { // Add a new DataColumn to the DataTable. DataColumn^ myColumn = gcnew DataColumn( "myTextBoxColumn" ); myColumn->DataType = String::typeid; myColumn->DefaultValue = "default string"; myTable->Columns->Add( myColumn ); // Get the ListManager for the DataTable. CurrencyManager^ cm = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]); // Use the ListManager to get the PropertyDescriptor for the new column. PropertyDescriptor^ pd = cm->GetItemProperties()[ "myTextBoxColumn" ]; // Create a new DataTimeFormat object. DateTimeFormatInfo^ fmt = gcnew DateTimeFormatInfo; // Insert code to set format. DataGridTextBoxColumn^ myColumnTextColumn; // Create the DataGridTextBoxColumn with the PropertyDescriptor and Format. myColumnTextColumn = gcnew DataGridTextBoxColumn( pd,fmt->SortableDateTimePattern ); // Add the new DataGridColumnStyle to the GridColumnsCollection. dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumnTextColumn ); }
private void AddColumn(DataTable myTable) { // Add a new DataColumn to the DataTable. DataColumn myColumn = new DataColumn("myTextBoxColumn"); myColumn.set_DataType(String.class.ToType()); myColumn.set_DefaultValue("default string"); myTable.get_Columns().Add(myColumn); // Get the ListManager for the DataTable. CurrencyManager cM = (CurrencyManager)(this.get_BindingContext(). get_Item(myTable)); // Use the ListManager to get the PropertyDescriptor for the new column. PropertyDescriptor pd = cM.GetItemProperties().get_Item("myTextBoxColumn"); // Create a new DataTimeFormat object. DateTimeFormatInfo fMt = new DateTimeFormatInfo(); // Insert code to set format. DataGridTextBoxColumn myColumnTextColumn; // Create the DataGridTextBoxColumn with the PropertyDescriptor and Format. myColumnTextColumn = new DataGridTextBoxColumn(pd, fMt. get_SortableDateTimePattern()); // Add the new DataGridColumnStyle to the GridColumnsCollection. dataGrid1.get_TableStyles().get_Item(0).get_GridColumnStyles(). Add(myColumnTextColumn); } //AddColumn
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
DataGridTextBoxColumn コンストラクタ
オーバーロードの一覧
名前 | 説明 |
---|---|
DataGridTextBoxColumn () | DataGridTextBoxColumn クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
DataGridTextBoxColumn (PropertyDescriptor) | PropertyDescriptor を指定して、DataGridTextBoxColumn の新しいインスタンスを初期化します。 |
DataGridTextBoxColumn (PropertyDescriptor, Boolean) | PropertyDescriptor を指定して、DataGridTextBoxColumn クラスの新しいインスタンスを初期化します。DataGridTextBoxColumn が既定の列かどうかを指定します。 |
DataGridTextBoxColumn (PropertyDescriptor, String) | PropertyDescriptor および書式を指定して、DataGridTextBoxColumn の新しいインスタンスを初期化します。 |
DataGridTextBoxColumn (PropertyDescriptor, String, Boolean) | 指定した PropertyDescriptor と書式を使用して、DataGridTextBoxColumn クラスの新しいインスタンスを初期化します。列が既定の列かどうかを指定します。 |
DataGridTextBoxColumn コンストラクタ (PropertyDescriptor, String)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
Dim prop As PropertyDescriptor Dim format As String Dim instance As New DataGridTextBoxColumn(prop, format)
表示されるデータのカスタム書式を作成するには、このコンストラクタを使用します。
DataGridColumnStyle は、列に表示されるデータの型を決定するために PropertyDescriptor を使用します。PropertyDescriptorCollection を返すには、BindingManagerBase クラスの GetItemProperties メソッドを使用します。
Private Sub MyAddCustomDataTableStyle() ' Get the currency manager for 'myDataSet'. Dim myCurrencyManger As CurrencyManager = CType(Me.BindingContext(myDataSet), CurrencyManager) Dim myTableStyle As New DataGridTableStyle() myTableStyle.MappingName = "Customers" Dim proprtyDescriptorName As PropertyDescriptor = myCurrencyManger.GetItemProperties()("CustName") Dim myCustomerNameStyle As DataGridTextBoxColumn = New DataGridTextBoxColumn(proprtyDescriptorName) myCustomerNameStyle.MappingName = "custName" myCustomerNameStyle.HeaderText = "Customer Name" myTableStyle.GridColumnStyles.Add(myCustomerNameStyle) ' Add style for 'Date' column. Dim myDateDescriptor As PropertyDescriptor = myCurrencyManger.GetItemProperties()("Date") ' 'G' is for MM/dd/yyyy HH:mm:ss date format. Dim myDateStyle As DataGridTextBoxColumn = New DataGridTextBoxColumn(myDateDescriptor, "G") myDateStyle.MappingName = "Date" myDateStyle.HeaderText = "Date" myDateStyle.Width = 150 myTableStyle.GridColumnStyles.Add(myDateStyle) ' Add DataGridTableStyle instances to GridTableStylesCollection. myDataGrid.TableStyles.Add(myTableStyle) End Sub 'MyAddCustomDataTableStyle
private void MyAddCustomDataTableStyle() { // Get the currency manager for 'myDataSet'. CurrencyManager myCurrencyManger = (CurrencyManager)this.BindingContext[myDataSet]; DataGridTableStyle myTableStyle = new DataGridTableStyle(); myTableStyle.MappingName = "Customers"; PropertyDescriptor proprtyDescriptorName = myCurrencyManger.GetItemProperties()["CustName"]; DataGridColumnStyle myCustomerNameStyle = new DataGridTextBoxColumn(proprtyDescriptorName); myCustomerNameStyle.MappingName = "custName"; myCustomerNameStyle.HeaderText = "Customer Name"; myTableStyle.GridColumnStyles.Add(myCustomerNameStyle); // Add style for 'Date' column. PropertyDescriptor myDateDescriptor = myCurrencyManger.GetItemProperties()["Date"]; // 'G' is for MM/dd/yyyy HH:mm:ss date format. DataGridColumnStyle myDateStyle = new DataGridTextBoxColumn(myDateDescriptor,"G"); myDateStyle.MappingName = "Date"; myDateStyle.HeaderText = "Date"; myDateStyle.Width = 150; myTableStyle.GridColumnStyles.Add(myDateStyle); // Add DataGridTableStyle instances to GridTableStylesCollection. myDataGrid.TableStyles.Add(myTableStyle); }
private: void MyAddCustomDataTableStyle() { // Get the currency manager for 'myDataSet'. CurrencyManager^ myCurrencyManger = dynamic_cast<CurrencyManager^>(this->BindingContext[ myDataSet ]); DataGridTableStyle^ myTableStyle = gcnew DataGridTableStyle; myTableStyle->MappingName = "Customers"; PropertyDescriptor^ proprtyDescriptorName = myCurrencyManger->GetItemProperties()[ "CustName" ]; DataGridColumnStyle^ myCustomerNameStyle = gcnew DataGridTextBoxColumn( proprtyDescriptorName ); myCustomerNameStyle->MappingName = "custName"; myCustomerNameStyle->HeaderText = "Customer Name"; myTableStyle->GridColumnStyles->Add( myCustomerNameStyle ); // Add style for 'Date' column. PropertyDescriptor^ myDateDescriptor = myCurrencyManger->GetItemProperties()[ "Date" ]; // 'G' is for MM/dd/yyyy HH:mm:ss date format. DataGridColumnStyle^ myDateStyle = gcnew DataGridTextBoxColumn( myDateDescriptor,"G" ); myDateStyle->MappingName = "Date"; myDateStyle->HeaderText = "Date"; myDateStyle->Width = 150; myTableStyle->GridColumnStyles->Add( myDateStyle ); // Add DataGridTableStyle instances to GridTableStylesCollection. myDataGrid->TableStyles->Add( myTableStyle ); }
private void MyAddCustomDataTableStyle() { // Get the currency manager for 'myDataSet'. CurrencyManager myCurrencyManger = ((CurrencyManager) (this.get_BindingContext().get_Item(myDataSet))); DataGridTableStyle myTableStyle = new DataGridTableStyle(); myTableStyle.set_MappingName("Customers"); PropertyDescriptor proprtyDescriptorName = myCurrencyManger.GetItemProperties().get_Item("CustName"); DataGridColumnStyle myCustomerNameStyle = new DataGridTextBoxColumn(proprtyDescriptorName); myCustomerNameStyle.set_MappingName("custName"); myCustomerNameStyle.set_HeaderText("Customer Name"); myTableStyle.get_GridColumnStyles().Add(myCustomerNameStyle); // Add style for 'Date' column. PropertyDescriptor myDateDescriptor = myCurrencyManger.GetItemProperties().get_Item("Date"); // 'G' is for MM/dd/yyyy HH:mm:ss date format. DataGridColumnStyle myDateStyle = new DataGridTextBoxColumn(myDateDescriptor, "G"); myDateStyle.set_MappingName("Date"); myDateStyle.set_HeaderText("Date"); myDateStyle.set_Width(150); myTableStyle.get_GridColumnStyles().Add(myDateStyle); // Add DataGridTableStyle instances to GridTableStylesCollection. myDataGrid.get_TableStyles().Add(myTableStyle); } //MyAddCustomDataTableStyle
private void MyAddCustomDataTableStyle() { // Get the currency manager for 'myDataSet'. CurrencyManager myCurrencyManger = ((CurrencyManager) (this.get_BindingContext().get_Item(myDataSet))); DataGridTableStyle myTableStyle = new DataGridTableStyle(); myTableStyle.set_MappingName("Customers"); PropertyDescriptor proprtyDescriptorName = myCurrencyManger.GetItemProperties().get_Item("CustName"); DataGridColumnStyle myCustomerNameStyle = new DataGridTextBoxColumn(proprtyDescriptorName); myCustomerNameStyle.set_MappingName("custName"); myCustomerNameStyle.set_HeaderText("Customer Name"); myTableStyle.get_GridColumnStyles().Add(myCustomerNameStyle); // Add style for 'Date' column. PropertyDescriptor myDateDescriptor = myCurrencyManger.GetItemProperties().get_Item("Date"); // 'G' is for MM/dd/yyyy HH:mm:ss date format. DataGridColumnStyle myDateStyle = new DataGridTextBoxColumn(myDateDescriptor, "G"); myDateStyle.set_MappingName("Date"); myDateStyle.set_HeaderText("Date"); myDateStyle.set_Width(150); myTableStyle.get_GridColumnStyles().Add(myDateStyle); // Add DataGridTableStyle instances to GridTableStylesCollection. myDataGrid.get_TableStyles().Add(myTableStyle); } //MyAddCustomDataTableStyle
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- DataGridTextBoxColumn コンストラクタ ()のページへのリンク