Part one described the sample application user experience.
Part two explained the main form engineering of the C# solution.
Part three described the C# solution IComparer sort machinery.
Part four here will explain the C# solution data display form, and wrap up with a brief description of the differences between the C# and VB.net example applications.
Download the sample C# / VB.net software at the GitHub repository.
The btn_load click event method
btn_load_RTB_Clickof CSharp_Demo_App.cs assembles and formats the display text, placing the text in variable recipe_text. Then, it declares and initializes localTextForm1, a textForm1 class instance, at line 230. This method disables the CSharp_Demo_App button controls, passes the recipe_text value to localTextForm1, and finally shows localTextForm1. CSharp_Demo_App sets the localTextForm1 recipe_text property value to recipe_text at line 235.
At line 26
|1. The textForm1 class|
Past syntax and a few code differences, the VB.net and C# applications are almost the same. The VB.net ColumnSorter class and code-behind files avoid the namespace / partial class syntax of the C# code. Additionally, the VB.net code-behind files avoid the InitializeComponent() calls found in the C# versions. Beyond this and language syntax differences, these applications are almost exactly the same.
This article showed that the IComparer Interface makes it easy to offer flexible, dynamic sort features in Windows desktop applications. Developers can focus on the business rules and requirements - IComparer will do the hard work.