i have two tables, one is for presented lessons and another is for the selected lessons by student, i want it to be like when student writes the code of lesson, a list of offered courses appear on first datagridview, and then when they click on one of the rows and click on "add" buttun, the selected row be added to the selected lesson table and appears on second datagridview.
1条答案
按热度按时间e3bfsja21#
Lacking specifics, here is a general example of how to populate the "presented lessons"
DataGridView
and adding/removing a row in the "selected lessons" DGV when selected. At least now you will have a starting point to experiment.It's usually easier to work with DGV if you make a
class
to represent a row of data.Next you declare lists that contain instances of your
Lesson
class.The binding lists are assigned to the respective DGVs when the main form loads. This method will also attach an event for when cell content (e.g. a checkbox) is clicked.
How to populate the first DGV:
Now all you have to do is handle the content click and either add the lesson to (or remove the item from) the second bound collection for the lesson that has changed.