C# – Datagridview selection column for Master-Detail relationship

cdatagridview

I have a Master-Detail relationship implemented with two Datagridview controls in c#. The datasources are each connected to a DataTable and the connection is done using a DataRelation. I added a checkbox column using "Add column" of the DataGridviewTask.

I want to achieve that I can use this checkbox to select / unselect a detail row which will then be related to the current master row. The relation between master and detail row should be 1 : 0..1. After selecting a detail row a method should be called which will save the info in a databse table.

At the moment I don't know how to achieve this, I even can't click on the checkbox (it's definitely not readonly), I assume it has something to do with the "DataPropertyName" of the checkbox column, but I don't know to which property I should set it to.

If anybody has an idea how to achieve this scenario (maybe there is even a free datagridview extension) I would really appreciate this.

Thanks
Daniel

Best Answer

For starters you should make sure there exists a boolean column for the checkbox. In a typed dataset you can easily add one using the DatasetDesigner.

Related Topic