我有一个绑定到 BindingSource 的 DataGridView(它是基于对象列表构建的)。我已使用 BindingSource 作为 DataGridView 的 DataSource,我想在ToString()
DataGridview 的一列中显示对象的方法。
我怎样才能做到这一点?
代码:
List<DynstSection> sectionlist = new blockloader.Blockloader(app).getDynStDb();
sectionlist.Sort();
bs_sections.DataSource = sectionlist;
listBox1.AutoGenerateColumns = false;
listBox1.DataSource = bs_sections;
DataGridViewColumn col = new DataGridViewCheckBoxColumn();
col.DataPropertyName = "Checked";
col.HeaderText = "Checked";
col.Name = "Checked";
col.Width = 20;
listBox1.Columns.Add(col);
DataGridViewColumn col2 = new DataGridViewTextBoxColumn();
col2.ReadOnly = true;
col2.DataPropertyName = HERE I WOULD LIKE TO HAVE TOSTRING()
col2.HeaderText = "Name";
col2.Name = "Name";
col2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
listBox1.Columns.Add(col2);