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

Wednesday, January 5, 2011

OCR In .net with MS-Office 2007 component (MODI)

I have been just passed through requirement to implement OCR in one of my .net application. There are very less option available in .net to implement it. I thought to share with you what I have learned at that time.

In .net OCR can be done with Ms-Office component, it’s the Microsoft Office Document Imagining Library. It is required to have ms-office on your pc before you develop or run this application. This component is available in both ms-office 2003 and 2007.

Initially when we install our office, it does not install image library in our pc, we need to install it explicitly. When you start to add/remove features in your office you need to check following things should be included.







Once you have installed it, you can start to develop your application.

You can take any project type either windows or console. Now you need to add reference of Document Imaging Library to your project, that will be available in com tab of add reference dialog box. Please note down that this will be only shown if you have installed it correctly. If you don’t able to see it though you have installed, try to restart your system and then check it again.




Once you have added that com reference you can work with images and can read text from it.


Tuesday, September 7, 2010

Difference between build and rebuild

In vs we find two options build and rebuild for our solution and very rarely we give attention what do we require.

There is very much difference between both of them, if you have noticed it, build takes less time compared to rebuild.

When we build application it complies files which has been changed it does not compile all files in project, while in case of rebuild it compiles all files weather it has been changed or not. Mainly rebuild should be done when so many files are changed and also it might possible some files are changed outside of IDE.

Hope this information will help to speed up your application when you choose rebuild instead of build.

Tuesday, August 10, 2010

Hide Tab Pages from Tab Control in Win forms

Recently I come to know one requirement to hide tab pages on my tab control of windows form depends on some condition.

I thought there could be some properties like Visible as we have in other controls. But surprisingly there is no such properties exist.

At the end I have only one solution to remove my tabpage from tab control. Let’s go through some code.

I have following tabControls.

myTabControl is my Tab Controls and I have following sub tabs(tab Pages) in it.

tabPage1

tabPage2

tabPage3

At index of 0, 1 and 2 respectively.

To hide my tabPage1 on my UI I have following options.

myTabControl.TabPaegs.Remove(0)

or

myTabControl.TabPages.Remove(tabPage1)

I hope this could be helpful when we have some condition for showing tabs.

Tuesday, July 20, 2010

Call customize Main method in Vb.net

If you have tried to find main method in vb.net, you would not able to find it because vb.net 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 Vb.net and recently I have added my custom main method, if you have been using vb.net 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 vb.net 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.

Application.SetCompatibleTextRenderingDefault(False)

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.