2015年11月19日 星期四

【WinForm】DataGridView AllowUserToAddRows doesn't work


The empty row we use to add new data at bottom is gone.
本來該出現在 DataGridView  最下面新增用那列不見了

AllowUserToAddRows 有設 True,它應該要有
這樣才對

問題在我用的是 BindingList<Someclass>  為資料來源,但在 SomeClass 中沒有不帶參數的建構子,所以 DataGridView 造不出空行來,只要補一個空的建構子給 SomeClass 即可。
  1. public class SomeClass
  2. {
  3. // Add an parameterless ctor, and the prob would be fixed
  4. public SomeClass()
  5. {
  6. }
  7. ...
  8. }


ref: StackOverFlow

沒有留言:

張貼留言