I found so many articles on the internet suggesting the need to write your own classes to read/write app.config. While the read is fairly easy, people are struggling a lot with the write, some are saying that write is not supported by .NET at all. There are numerous examples and training articles on how to get started with writing your own classes for that. Well guess what - you don’t need to write your own classes.
Here I am going to show some basics of custom drawing in VB.NET. This is not production-class code, but rather a head start for those assessing whether or not it's feasible to custom draw anything (result vs effort). In this sample project, I will highlight all even items of a ListBox with LightGray color.
Relaxed delegate conversion enables you to assign subs and functions to delegates or handlers even when their signatures are not identical. In practice, it means that the following code [...] Can be written like this ... If you don't need to use event arguments, such as in the above scenario, your code becomes much more readable by omitting argument clause. For developers coming from C# background - yes, everything will work here, even with `Option Strict On`. Everything, but one thing...
While it may appear to be a simple question, there is really more to it. Please read this article carefully, even if you believe you know how to handle this situation. And especially if you have been writing command line utilities for 10+ years and never encountered any issues using standard .NET functionality. Approaches you may be thinking about at the moment, which are often suggested at forums, unfortunately, do not work:
I tested this on HTML pages and it appears to be not the most efficient. In one of the examples, ~140K down to 44K. In comparison, Total Commander can zip down to 27K at the average compression level. But even with minimal compression the file remains at 32K.
There is one good way to dynamically show/hide items in a ListBox - use a DataView as DataSource. You do not need to manually Add and Remove items from your list. In fact, coding effort is very low with this approach.
Suppose every once in a while in your application you need to have a popup dialog being shown. This dialog is a value picker, nothing more. It shows as many values as your screen can handle. Problem happens when list population takes considerable amount of time, say, 5 seconds. Until then you are completely unsure which size it needs to resize to.
Linearise ControlCollection tree into array of Control - generic extension method, no recursion, LINQ or GetNextControl. See attached project for usage/sample (VB.NET 4.0, Visual Studio 2010).
Here is a proper way to do it - inherit a class from native ComboBox and override OnDropDown to raise a custom DropDownOpening event first. If you anticipate loading to take considerable time, you can wrap your reload code into a construct like this
I recently stumbled upon this problem in one of our company .NET projects. For some reason, project settings there were configured for Text comparison, rather than Binary. As a result, lower case strings were equal to upper case, which was discovered later when some bug in UI occured. There were three solutions available.