DataGridViewColumnCollection クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Class DataGridViewColumnCollection Inherits BaseCollection Implements IList, ICollection, IEnumerable
public ref class DataGridViewColumnCollection : public BaseCollection, IList, ICollection, IEnumerable

このクラスのインスタンスは、DataGridView コントロールの Columns プロパティを使用して取得できます。このコレクションは、DataGridView プロパティを通じてコントロールへの参照を保持します。

Private WithEvents dataGridView1 As New DataGridView() Private Sub AddColorColumn() Dim comboBoxColumn As New DataGridViewComboBoxColumn() comboBoxColumn.Items.AddRange( _ Color.Red, Color.Yellow, Color.Green, Color.Blue) comboBoxColumn.ValueType = GetType(Color) dataGridView1.Columns.Add(comboBoxColumn) End Sub Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, _ ByVal e As DataGridViewEditingControlShowingEventArgs) _ Handles dataGridView1.EditingControlShowing Dim comboBox1 As ComboBox = CType(e.Control, ComboBox) AddHandler comboBox1.SelectedIndexChanged, _ New EventHandler(AddressOf ComboBox_SelectedIndexChanged) End Sub Private Sub ComboBox_SelectedIndexChanged( _ ByVal sender As Object, ByVal e As EventArgs) Dim comboBox1 As ComboBox = CType(sender, ComboBox) comboBox1.BackColor = _ CType(CType(sender, ComboBox).SelectedItem, Color) End Sub
private DataGridView dataGridView1 = new DataGridView(); private void AddColorColumn() { DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn(); comboBoxColumn.Items.AddRange( Color.Red, Color.Yellow, Color.Green, Color.Blue); comboBoxColumn.ValueType = typeof(Color); dataGridView1.Columns.Add(comboBoxColumn); dataGridView1.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler( dataGridView1_EditingControlShowing); } private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { ((ComboBox)e.Control).SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); } private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { ((ComboBox)sender).BackColor = (Color)((ComboBox)sender).SelectedItem; }

System.MarshalByRefObject
System.Windows.Forms.BaseCollection
System.Windows.Forms.DataGridViewColumnCollection


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


- DataGridViewColumnCollection クラスのページへのリンク