Adding rows programatically to a DataGridView that is data bound?

后端 未结 2 1146
逝去的感伤
逝去的感伤 2020-12-12 02:01

I have a problem and I can\'t seem to be able to solve it. I thought someone here will be able to help out.

I have a form that has a DataGridView of customers. Now,

相关标签:
2条回答
  • 2020-12-12 02:19

    In order to show those rows, just do a UNION (-like) action before the databinding. Ie get your list of records, add the special ones and then databind.

    Updating will require some special action(s) too. But with a total lack of details about your datastructures it's impossible to say what.

    0 讨论(0)
  • 2020-12-12 02:27

    Bind your DGV to a BindingList<YourObject>, where YourObject can be a simple class with properties reflecting your database schema. Initially populate the BindingList from the database, and the DGV will automatically add YourObject instances to the list. When you're ready to commit the changes, do so manually from the BindingList.

    0 讨论(0)
提交回复
热议问题