C#でDataGridView.Columns[0]に自作プロパティを作成する方法
class1.cs
public class CusDataGridViewColumn: DataGridView
{
public new List<CustumColumn> Columns { get; }
public CustumColumn this[int index] // インデクサ
{
get
{
return Columns[index];
}
set
{
Columns[index] = value;
}
}
}
public class CustumColumn : DataGridViewColumn
{
public string test { get; set; }
}
Form1.cs
private void Form1_Load(object sender, EventArgs e)
{
string a = cusDataGridViewColumn1.Columns[0].test;
a = cusDataGridViewColumn1.Columns[1].test;
}