我可以使用哪种控制方法快速提供我的列表集的可视化编辑 我在内存中的收藏如下。
我的要求基本上是:
我的代码
private static List<ConfigFileDTO> files;
public class ConfigFileDTO
{
private string filename, content_type, path;
private int file_size;
private DateTime updated_at;
public ConfigFileDTO() { }
public int FileSize {
get { return this.file_size; }
set { this.file_size = value; }
}
public string ContentType {
get { return this.content_type; }
set { this.content_type = value; }
}
public string Filename {
get { return this.filename; }
set { this.filename = value; }
}
public DateTime UpdatedAt {
get { return this.updated_at; }
set { this.updated_at = value; }
}
public string Path {
get { return this.path; }
set { this.path = value; }
}
}
由于
答案 0 :(得分:2)
如果您只想操作Path
列,那么通常最好只需手动设置列绑定(对于像DataGridView
这样的东西);但是,您也可以使用[Browsable(false)]
(从显示中删除属性)和[ReadOnly(true)]
(将属性视为只读,即使它有一个setter)来控制属性(/ columns)的方式处理。
如果您想控制新实例的创建方式,请从BindingList<T>
继承并覆盖AddNewCore()
。