Archive for the ‘Programming’ Category

Adding your own Custom Control to a Windows forms Context Menu

March 6, 2009

Ever wanted to show your own custom control, inside the windows forms context menu? has a nice article with how-to video.


Orientation aware control for Mobile

December 27, 2008

I have been involved in developing mobile web applications for almost a year and half now. In this period I developed few applications where the requirement was to change the orientation of the layout (horizontal to vertical and vice-versa) automatically based on device width. Some times (in case of new age phones like iPhone, Storm) this may be also depending on the how the device is being currently viewed.

In such scenario’s we used to break lot of our head to make the page work and yet support different orientations supported by the phone. In achieving this we used to end up having either two layouts or change the controls location based on the current orientation of the phone/device. This is really a time consuming job and very boring job for a person like me.

Today, I found a user control called Orientation Aware Control, which automatically does this job for us. Although this is not free control, it supports classic phones to the Windows Mobile 6.0/6.1.

From OAC website:

The Orientation Aware Control allows designing and coding a single control or form with multiple layouts or skins that are automatically applied at run-time (and design-time) according to the available form factor, resolution and orientation. Its outstanding Visual Studio forms and user control designer integration and zero-code adaptive UI behavior make the Orientation Aware Control a must-have companion for any mobile shop targeting multiple devices, bringing back the productivity you need to focus on growing your business.

ObjectListView control

December 18, 2008

I am developing an Visual Studio package from long time to improve the time spent in reviewing code in my organization. It is in final stages of development now. In this package I have a requirement to show a tabular data for which I was using .NET list view control till 2-3 days back.

As many may know, the .NET list view control does not have built in features like column-wise sorting, alternate row colors, showing graphics etc. Though you can achieve all this in .NET list view control, it involves a extra coding from your side. Hence I was in search of perfect list view control from few days.

Finally I found a free control in The control is called as ObjectListView.

I am using this from past 2-3 days, and I am loving it. There are huge number of customizations available inside this control and I still need to explore them.  Also this control comes in different forms like, TreeListView, VirtualObjectListView etc.

Below are few screenshots of the control.


Singleton Pattern vs. Static Class

November 13, 2008

The singleton pattern ensures a class has only one instance, and provide a global point of access to it.

There is a nice article about choosing between Singleton pattern and the static class here with examples.

DebuggerStepThrough attribute

November 6, 2008

Pedram Rezaei has written how we can let .NET debugger know, not to step in to certain elements of your program with the help of DebuggerStepThroughAttribute.

Read it here

TypeCode enum in C#

June 9, 2008

Recently, one of my friend digged in to metadata of TypeCode enum type and found out that, it does not have value 17 in it.

imageEven I was surprised to see this, and wanted to know the reason behind value 17 missing from the enumeration.

I googled and found a link to blog which explains, why the value 17 has been missed from the enum.

From the author:

We’ve had this “hole” in the TypeCode enum since October of 2000, and I can’t find an older set of bits. But, I’m sure that comment in IConvertible is right – this used to be TimeSpan. For TimeSpan, it’s possible we thought it would be interesting for a while, then we realized that frankly not that many people need to convert a Decimal to a TimeSpan, then removed it.

You might ask why we didn’t “fix” the enum when we removed whichever of these values we had originally added. It turns out that whenever we have a breaking change internally, we need to recompile all the code that might possibly depend on the removed or changed public surface area. For us, that would mean rebuilding everything that might have referred to TypeCode.String, whose value would have changed from 18 to 17. While we do go through that process internally in DevDiv, it is costly & painful for us.

Accessing Master page properties

May 14, 2008

Other day I needed to access the property defined in Master page and was facing an issue. The issue was what if the master page is renamed? The namespace would change and it will break the code.

I googled for a better option and found exactly what I wanted. Below is the link where the author has neatly explained how this can be done.


March 19, 2008

Hmm, yes! I was struggling not to sleep from past one hour and was doing all sorts of stuff (read News, gone through MSDN magazine, read RSS feeds and lastly tea) to avoid it Smile. Finally I am in a state to write this blog.

Well, I am coming up with a new tool and I am adding “Check for Update” feature to the tool. Though I am almost done with the main updating feature, but I am still struggling to add an option to show the user file download size. You might ask me what is the big fuss in that?

I do not want to keep the file sizes in some file on the server and read it from my tool. Basically I want to get the file size in the server before downloading it.

I have seen this kind of feature in many of the download managers like Free Download Manager(FDM). The FDM has a feature like have a Query size (see screenshot below), which tells you the download size before you actually start the download.


Click Query size and you will get the following screen.


I am working towards to achieve something similar. Hoping to find some solution soon!

ASP.NET State Server error!

February 20, 2008

After a full day work, I deployed my project which is an mobile web application, on to a testing server yesterday. The application is built using .net framework 1.1.

After deployment, I hit the URL in the web browser, and to my shock got the below error.


Thankfully, the error stated how to resolve error “Please ensure that the ASP.NET State service is started…”. I hit services.msc from run menu and yes, ASP.NET State Service was not running!. I started it, and refreshed the URL, the page appeared!

Good that I fixed the problem immediately, thanks to for conveying error neatly this time!

Batch printing?

December 1, 2006

In my current project I had to implement Batch Print feature in a web application. Basically, the requirement was, in an ASPX page you have a datagrid listing a set of files in first coulmn and in the second column you would have a checkbox, which would allow user to select a group of files to print. below this grid you will have a button to Print. So when user selects a particular set of files using checkbox and then clicks on the Print button you should print the documents one-by-one silently, i.e, without opening the associated application. Digging few articles in CodeProject I was able to implement it. The code worked successfully in filesystem, in VS.NET 2005. But when I published the same project in IIS and ran, it gave me an error. I am breaking my head to solve it.