WinForms: How to handle DataGridViewButtonColumn click event

There’s not a direct way to handle the DataGridViewButtonColumn button click event. Instead, you have to: Handle the DataGridView.CellContentClick event. Check if they clicked the button column. Execute the button click handling logic, passing in the bound data item. In this article I’ll show a step-by-step example of how to handle the button click. Example … Read more

ReportViewer RDLC – How to show an enum’s string representation

Problem I’m building a report using ReportViewer. I’m setting the Data Source to a collection of model objects. One of the fields on the model is an enum. When the report renders, it is showing the enum’s numeric value. I want it to show the string representation of the enum instead. Solution In the field … Read more

System.InvalidOperationException: Objects added to a BindingSource’s list must all be of the same type.

Problem I am building a report using ReportViewer RDLC and I’m trying to bind the data. When I try to add my BindingList to the BindingSource I get the following exception: System.InvalidOperationException: “Objects added to a BindingSource’s list must all be of the same type.” Here’s the code causing this: Solution Set the BindingSource.DataSource to … Read more