Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有自定义类,我想重写 OnDataSourceChanged 方法来读取有关列的一些信息。但是在这种方法中,尚未生成列。我只能访问数据源列,但我需要访问自动生成的 DataGridView 列集合。这些列是什么时候生成的?
您没有发布代码,但请确保base.OnDataSourceChanged()在尝试访问网格控件的列集合之前调用该方法:
base.OnDataSourceChanged()
protected override void OnDataSourceChanged(EventArgs e) { base.OnDataSourceChanged(e); // call this first // loop through columns here... }