Sometimes it’s important to understand the order of events that occur when a WinForms Form is opened, closed, shown or hidden. There are also a few “gotchas” that are important to know.
The C# decimal keyword denotes a 128-bit data type. Compared to floating-point types, the decimal type has a greater precision and a smaller range, which makes it suitable for financial and monetary calculations.
Approximate Range: ±1.0 × 10−28 to ±7.9 × 1028
Precision: 28-29 significant digits
.NET Type: System.Decimal
It’s common UI courtesy to show the Wait cursor when performing a long operation that requires the user to wait. Here is how the Wait cursor appears in Windows Vista:
But developers often go about this the wrong way by setting the Cursor.Current property as follows:
Cursor.Current = Cursors.WaitCursor;
Sometimes you may need to display or print an input string that contains binary characters. The following function replaces all binary characters in a string with a blank. You can easily modify this method to remove other undesirable characters (such as high-ASCII) if needed.
Closing all forms in an application seems like it would be a simple task of using a foreach loop in the Application.OpenForms collection, such as:
foreach (Form form in Application.OpenForms) { form.Close(); }
But there are two problems.
It’s easy to read a string one line at a time. Here is a console program that demonstrates how:
It’s fairly easy to convert a C# String to a Stream and vice-versa.
So you’ve set the ToolTipText property of a TabPage in a TabControl. When the user moves the mouse pointer over the tab, the text you specified is supposed to show in a tooltip.
But what if the tooltip is not showing? Fortunately, this problem has an easy solution:
Set the ShowToolTips property in the TabControl to true.
Many .NET developers are baffled by the lack of a “Clear” method in the StringBuilder class. For example, if you are using a StringBuilder in a loop, you may want to clear its contents at the beginning of each loop.
This article explains how to use C# to determine the name, edition, service pack, version and bits of the host operating system.
For example, the results on my PC would be:
Operation System Information
—————————-
Name = Windows Vista
Edition = Home Premium
Service Pack = Service Pack 1
Version = 6.0.6001.65536
Bits = 64