You should be able to develop your code and design sense to the point where you can look at anyone’s code (including your own) and intuitively know if it’s good or not. This is a critical skill to have if you are responsible for doing code and design reviews. Here’s some suggestions based on what … Read more Improve your code and design intuition
In this article I’ll be showing how to use custom attributes in C#. As an example, I’m creating a Console app that color codes output based on a status. Here’s what this looks like: What is an attribute? First of all, what is an attribute? Attributes are a clean way to add additional information about … Read more C# – Using custom attributes
Problem I have created a custom attribute class and I am trying to pass in a value. It looks like this: I’m getting the following error message: Attribute constructor parameter has type Color which is not a valid attribute parameter type I have also gotten this error message, which has the same underlying cause: An … Read more C# – Attribute constructor parameter is not a valid attribute parameter type
I am building a ReportViewer report and need to format phone numbers. For example, I want “5551234” to be formatted as “555-1234.” Specify the phone number format Use the following expression: Now when I run the report it looks like this: Other formatting examples In my example above I was using a very simple format. … Read more ReportViewer – How to format phone numbers
Problem You’re getting the following error when compiling: Could not find an implementation of the query pattern for source type ‘Your Type’. ‘Select’ not found. Solution The error message is odd, but the solution is simple. Add this: I’ve only ran into this in older versions of VS.
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 ReportViewer RDLC – How to show an enum’s string representation
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 System.InvalidOperationException: Objects added to a BindingSource’s list must all be of the same type.
Problem You’re trying to use the ReportViewer control in Visual Studio but it’s not in the toolbox. Other symptoms: After manually adding the ReportViewer control to the toolbox clicking Design a new report does nothing. The RDLC report designer does not open and opening the RDLC file just opens the report markup. Solution Note: I … Read more ReportViewer doesn’t appear in the toolbox in Visual Studio
Problem When entering the sa password while installing SQL Server you get the following error: “The specified sa password does not meet strong password requirements.“ Solution If the computer is on a domain Go to Administrative Tools / Domain Security Policy :: Security Settings | Account Policies | Password Policy Set “Minimum password length” = Not … Read more The specified sa password does not meet strong password requirements
Problem I am parsing CSV data and a string field contains commas. For example: The split string for the 3rd line will produce the array: The solution is to merge the slots that belong to the string field. In the example above, you would merge indexes 0 and 1. Code Tests