DataGridColumnStyle コンストラクタ (PropertyDescriptor)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)


新しい DataGridColumnStyle を作成するには、最初に列を追加するテーブルのデータ ソースの CurrencyManager を取得する必要があります。フォームの特定の CurrencyManager オブジェクトを取得する方法については、CurrencyManager および BindingManager のトピックを参照してください。
CurrencyManager から、列のデータを提供する DataColumn の PropertyDescriptor を取得できます。
DataGridColumnStyle のインスタンスを作成すると、次の読み書き可能プロパティが初期化されます。

新しい DataGridTextBoxColumn (DataGridColumnStyle から派生) を作成し、DataGridTableStyle の GridColumnStylesCollection に追加するコード例を次に示します。
Private Sub CreateNewDataGridColumnStyle() Dim myDataSet As New DataSet("myDataSet") ' Insert code to populate the DataSet. ' Get the CurrencyManager for the table you want to add a column to. Dim myCurrencyManager As CurrencyManager = CType _ (Me.BindingContext(myDataSet.Tables("Suppliers")), CurrencyManager) ' Get the PropertyDescriptor for the DataColumn. Dim pd As PropertyDescriptor = _ myCurrencyManager.GetItemProperties()("City") ' Construct the DataGridColumnStyle with the PropertyDescriptor. Dim myColumn As New DataGridTextBoxColumn(pd) myColumn.MappingName = "City" dataGrid1.TableStyles(0).GridColumnStyles.Add(myColumn) End Sub
private void CreateNewDataGridColumnStyle(){ DataSet myDataSet = new DataSet("myDataSet"); // Insert code to populate the DataSet. // Get the CurrencyManager for the table you want to add a column to. CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[myDataSet, "Suppliers"]; // Get the PropertyDescriptor for the DataColumn. PropertyDescriptor pd = myCurrencyManager.GetItemProperties()["City"]; // Construct the DataGridColumnStyle with the PropertyDescriptor. DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd); myColumn.MappingName = "City"; dataGrid1.TableStyles[0].GridColumnStyles.Add(myColumn); }
void CreateNewDataGridColumnStyle() { DataSet^ myDataSet = gcnew DataSet( "myDataSet" ); // Insert code to populate the DataSet. // Get the CurrencyManager for the table you want to add a column to. CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[myDataSet, "Suppliers"]); // Get the PropertyDescriptor for the DataColumn. PropertyDescriptor^ pd = myCurrencyManager->GetItemProperties()[ "City" ]; // Construct the DataGridColumnStyle with the PropertyDescriptor. DataGridColumnStyle^ myColumn = gcnew DataGridTextBoxColumn( pd ); myColumn->MappingName = "City"; dataGrid1->TableStyles[ 0 ]->GridColumnStyles->Add( myColumn ); }
private void CreateNewDataGridColumnStyle() { DataSet myDataSet = new DataSet("myDataSet"); // Insert code to populate the DataSet. // Get the CurrencyManager for the table you want to add a column to. CurrencyManager myCurrencyManager = (CurrencyManager)(this.get_BindingContext(). get_Item(myDataSet, "Suppliers")); // Get the PropertyDescriptor for the DataColumn. PropertyDescriptor pd = myCurrencyManager.GetItemProperties(). get_Item("City"); // Construct the DataGridColumnStyle with the PropertyDescriptor. DataGridColumnStyle myColumn = new DataGridTextBoxColumn(pd); myColumn.set_MappingName("City"); dataGrid1.get_TableStyles().get_Item(0). get_GridColumnStyles().Add(myColumn); } //CreateNewDataGridColumnStyle

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridColumnStyle コンストラクタ

名前 | 説明 |
---|---|
DataGridColumnStyle () | 派生クラスで、DataGridColumnStyle クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
DataGridColumnStyle (PropertyDescriptor) | PropertyDescriptor を指定して、DataGridColumnStyle クラスの新しいインスタンスを初期化します。 |

関連項目
DataGridColumnStyle クラスDataGridColumnStyle メンバ
System.Windows.Forms 名前空間
DataColumn
DataGrid クラス
DataGridColumnStyle コンストラクタ ()
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataGridColumnStyle コンストラクタのページへのリンク