Windows Forms Interview Questions and Answers (13) - Page 1

How to disable the default ContextMenu of a TextBox?

By creating new object of ContextMenu class,we can disable ContextMenu of a TextBox.

txt_name.ContextMenu = new ContextMenu();
What is Context menus in Windows Application?

Context menus are menus that appear when we do right-click from Mouse.Context menus are created with the ContextMenu component.
What are the two types of properties in Dot Net?

We have 2 properties in Dot Net which are Get and Set.

Get is called as Read-only property whereas Set is used for setting any values to variables i.e. it's Write-only property.
Get is used for getting values from variables.
What are the data-types used in value types and reference types?

Value type - bool,byte,chat,decimal,double,enum,float,int,
long, sbyte, short, strut, uint, ulong,ushort.

These are stored in the Stack.

Reference type - class,delegate,interface,object,string.

These are stored in the Heap.
How to give Line Break in Windows Application in C#?

We use \r\n for giving Line Breaks in C# Windows Application.

For Example:-
string str = "This is \r\n a Dot Net Funda Website";

What is an alternative way of giving a Line Break in C# Windows Application?

We have also an Environment.NewLine static method which gives a Line Break.

For Example:-
string str = "This is \r\n a Dot Net Funda website" + Environment.NewLine + "Hello World";

How to give Line Break in Windows Application in VB.Net?

We use vbCrLf in-built VB.Net function for giving Line Breaks in Vb.Net Windows Application.

For Example:-
string str = "This is" & vbCrLf & "a Dot Net Funda Website"

What is the difference between \r\n and vbCrLf?

Both is used for giving Line Breaks in Text in Windows Application.But there is a little difference between them.

\r\n is used in C# whereas vbCrLf is used in VB.Net.
Explain the key events in the Lifecycle of the form.

a. Load: fired when form is first loaded in the application
b. Activated: fired whenever the form gets the focus i.e. when loaded first time, restored from the minimize state, whenever the form is brought in front.
c. Deactivated: fired whenever the form looses focus i.e. when form is closed, minimized, when it is in background.
d. Closing: Triggered when application wishes to be closed.
e. Closed: Triggered when application is closed.
f. Disposed: Used for garbage collection.
Which property is used for making letters as Uppercase or Lowercase?

NOTE: This is objective type question, Please click question title for correct answer.
Which property is used to get Screen Width and Height?

We can use Screen.PrimaryScreen.WorkingArea property and assign it to System.Drawing.Rectangle object to get Height and Width of windows.
Explain the key events in the life-cycle of the windows form?

Life-cycle of the windows form are:-
a. Load: fired when form is first loaded in the application
b. Activated: fired whenever the form gets the focus i.e. when loaded first time, restored from the minimize state, whenever the form is brought in front.
c. Deactivated: fired whenever the form looses focus i.e. when form is closed, minimized, when it is in background.
d. Closing: Triggered when application wishes to be closed.
e. Closed: Triggered when application is closed.
f. Disposed: Used for garbage collection.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories