Mital Kakaiya [MCSD.NET]
In Programming, Logic is everything.

.NET Framework

True Random Number/String Generator

System.Random class SDK indicates that Pseudo-random numbers are chosen with equal probability from a finite set of numbers. The chosen numbers are not completely random because a definite mathematical algorithm is used to select them, but they are sufficiently random for practical purposes. The random number generation starts from a seed value. If the same seed is used repeatedly, the same series of numbers is generated. for(int index=0; index<10; index++) { int seed = (int) System.DateTime.Now.Ticks; ......

Developing a custom collection editor

.NET framework has a collection editor, which provides design-time user interface to edit most types of collections. Last month, I needed custom collection editor at design-time, including hidden Add/Remove buttons, custom properties events, collection item validation rules etc... I have designed a custom collection editor form called "CollectionManager", which fires custom events as follow: #Region " Event Handler " Public Event BeforeAddItem As CancelEventHandler Public Event AfterAddItem As EventHandler ......

Visual Studio 2005 IDisposable interface

IDisposable is a common interface to release allocated unmanaged resources. Many developers implement IDisposable incorrectly, which causes memory leak inside an application.More Info: http://www.bluebytesoftware... and http://dotnetjunkies.com/We... I wrote Implements IDisposable and press ENTER, Visual Studio 2005 (Beta 2) VB.NET project, it does as follow: (added code snippet ......

Never use LostFocus event

I was working with complex usercontrol with a grid and child usercontrols, which raises certain delegates (events). After in-depth code dubug, LostFocus event does not fire in same sequence, when control lost it's focus using KeyBoard or Mouse as specified in MSDN documentation. The issue is:When cancel property of the CancelEventArgs object is set to true in the Validating event delegate, all events that would normally occur after the Validating event are suppressed. It indicates that LostFocus ......

.NET Programming Tools

MSDN has created C# (and VB.NET) code library, utility, IDE, add-in and other .net related tools here.

How to handle special key events?

Microsoft .NET Framework has KeyUp, KeyPress and KeyDown events. These events capture only limited character set. Also, Arrow keys do not fire KeyPress and KeyDown events, but it fires KeyUp event.Now application needs to capture TAB/Arrow keys efectively, before any part of the application reads or fires any events. Also how to disable certain keys within an application? To handle special key events at the form or control level, overrides protected ProcessCmdKey function as follow:Protected Overrides ......

Resize Image - A better way

I have created "Resources" project to store all resource information across projects like icons, images, string, messages, etc... This helps my team to develop application faster, more robust, easy to update resources, and most important, globalization supports. To reduce overhead of the resources with an application interaction, I have created a simple ArrayList collection with a singleton class. It loads all images and icons inside memory when application starts. (I know it occupies lots of memory, ......

Hello World :)

To keep programming geek's tradition, I start with “Hello World” example in .NET: .assembly HelloWorld { .ver 1:0:1:0 } .method public static void Main(string[] args) cil managed { .custom instance void [mscorlib]System.STAThreadA... .entrypoint .maxstack 8 L_0000: ldstr "Hello World" L_0005: call void [mscorlib]System.Console::W... L_000a: ret } dp.SyntaxHighlighter.Highli... true, true); Don't worry, I am not an IL programmer. I am working ......