this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, July 20, 2010

Call customize Main method in

If you have tried to find main method in, you would not able to find it because automatically generates that method at runtime. We don’t require writing it. Developer who have worked with C# may find this problem most.

You can write your own main method that can be used at runtime. You can write your main method in a class or a module like below.

But you need be aware of one thing on your project properties

Application->uncheck Enable application framework. In this case, your main method will be invoked instead of automatic generated one.

To Fix Label’s and other controls text are wrapping though it looks Okay in Designer

Recently I have faced a very strange problem in my project, suddenly in some forms text of label wrapped when I run application.

I have not changed anything in my designer or code, though it was creating problem at runtime. I have compared my forms with older version, I also went through each of possible design property of forms but I didn’t find anything.

I had no idea what to do. Then I came to know that my project is in and recently I have added my custom main method, if you have been using you would be aware there is no main method, framework create it runtime. But if you want to do something at startup you need to write main method in application.

So I got what the problem it was.

By default when runtime create main method it uses following setting for text render but if you are using your own main method at that time you need to add this line to your main method else it can create problem what I have faced.


Saturday, July 17, 2010

Bind Enum to windows dropdown box.

Sometime our dropdown lookup value are fixed and we don’t have any database table. In such situation we mostly make enum of our look up value.

But most of the time we are used to bind datasource of tables or list to combbox. So we might be wonder how to bind our enum to combobox.

Here is the simple way to bind combobox.

Say for example you have RoleTypes Enum.

public enum RoleTypes


Owner = 1,

Manager = 2,

AssitManager = 3,

Employee = 4


Now, to bind this enum to our combo box.

this.cmbUserRole.DataSource = Enum.GetValues(typeof(RoleTypes));

Set value to combobox.

this.cmbUserRole.SelectedItem = (RoleTypes)1;

To get value from combobox.

Convert.ToInt32((RoleTypes) this.cmbUserRole.SelectedItem);

Monday, July 12, 2010

Change Local Working Folder Path in TFS…

Hi, all

Before a few days ago, I was using TFS as our version control system. When I tried to get latest for first time, It asked me for local path where It would be copied from server.

Later on, I needed to change my local path to somewhere else and when I was looking in TFS window to change my local path, I was wondered there were no such options which leads me to change my local working path.

I tried to find in web and I got solution.

In VsàFile menuàSource ControlàWork Space this will leads you a dialog box which shows all workspace on your computer.

You can change any of the lists by editing it.

I hope this will be helpful.

Thursday, July 1, 2010

Declare Guid as Constant.

If you have tried to declare Guid constant with keyword, const you definitely come to error that Guid can’t be declared as constant.

We can only use Const keyword for the value type not for the Object type. Here Guid is object type. You can get to know your datatype is value type or object type by the color of it.

Like value type always shows in blue text(link) while reference type shows in skyblue.

We can use readonly keyword for object type.

We can declare constant of guid as

readonly Guid myId = Guid.NewGuid();

After all our goal is that nobody can change value of our variable and that can be achieved by above.