Interview questions and answers for C# and VB.NET Windows Application, Windows Form
User Interface. Visual Studio Windows Forms, User Interface Design, Controls, Container
controls, Text Box, Form level and filed level Validation, Error and Help Provider,
Context Menu, Shortcut Keys, Access Keys, Custom Controls, Docking, Control License
Provider, Form Event.
.NET 2.0, 3.0, 3.5, 4.0, 4.5 User Interface related interview question and answers
1. You are creating an application for a major bank. The application should
integrate seamlessly with Microsoft Office, be easy to learn, and instill a sense
of corporate pride in the users. Name two ways you might approach these goals in
the user interface.
Design the user interface to mimic the look and feel of Microsoft Office , which
will allow users of Office to immediately feel comfortable with the new application.
Integration of the corporate logo and other visual elements associated with the
company will aid in identification of the program with the company
2. You are writing an application that needs to display a common set of controls
on several different forms. What is the fastest way to approach this problem?
Create a single form that incorporates the common controls, and use visual inheritance
to create derived forms.
3. If you wanted to prompt a user for input every time a form received the focus,
what would be the best strategy for implementing this functionality?
Write an event handler for the Activated event that implements the relevant functionality.
4. Describe two ways to set the tab order of controls on your form.
You can set the tab order in Visual Studio by choosing Tab Index from the View menu
and clicking each control in the order you desire. Alternatively, you can set the
TabIndex property either in code or in the Properties window.
5. What is an extender provider, and what does one do?
Extender providers are components that provide additional properties to controls
on a form. Examples include the ErrorProvider, HelpProvider, and ToolTip components.
They can be used to provide additional information about particular controls to
the user in the user interface.
6. Explain when you might implement a shortcut menu instead of a main menu.
If every possible option is exposed on a main menu, the menu can become busy and
hard to use. Shortcut menus allow less frequently used options to be exposed only
in situations where they are likely to be used
7. Describe what is meant by field-level validation and form-level validation.
Field-level validation is the process of validating each individual field as it
is entered into a form. Form-level validation describes the process of validating
all of the data on a form before submitting the form.
8. Describe how to retrieve the ASCII key code from a keystroke. How would you
retrieve key combinations for non-ASCII keys?
Keystrokes can be intercepted by handling the KeyPress and KeyDown events. Both
of these events relay information to their handling methods in the form of their
EventArgs. The KeyPressEventArgs, relayed by the Key-Press event, exposes the ASCII
value of the key pressed in the KeyPressEventArgs. KeyChar property. The KeyEventArgs,
relayed by the KeyDown event, exposes properties that indicate whether non-ASCII
keys such as ALT, CTRL, or Shift have been pressed. To retrieve the ASCII key code
from a keystroke, you would handle the KeyPress event and get that information from
the KeyPressEventArgs.KeyChar property. To retrieve non-ASCII information, you would
handle the KeyDown event and use the properties exposed by the KeyEventArgs instance.
9. Describe in general terms how to add a control to a form at run time.
You must first declare and instantiate a new instance of the control. Then, you
must add the control to the form's Controls collection. Once the control has been
added to the Controls collection, you must manually set properties that govern the
control's position and appearance.
10. What is container controls ?
Controls that can host other controls. Examples include Forms, Panels, and TabPages.
11. What is docking?
In Windows Forms, attaching a control to the edge of the form. You can dock a control
by setting the Dock property.
12. What is Access Keys?
Access keys allow users to open a menu by pressing the Alt key and typing a designated
letter. When the menu is open, you can select a menu command by pressing the Alt
key and the correct access key. For example, in most programs, the Alt+F key opens
the File menu. Access keys are displayed on the form as an underlined letter on
the menu items.
13. What is Shortcut keys?
Shortcut keys enable instant access to menu commands, thus providing a keyboard
shortcut for frequently used menu commands. Shortcut key assignments can be single
keys, such as Delete, F1, or Insert, or they can be key combinations, such as Ctrl+A,
Ctrl+F1, or Ctrl+Shift+X. When a shortcut key is designated for a menu item, it
is shown to the right of the menu item.
14. What is Context menus?
Context menus are menus that appear when an item is right-clicked. Context menus
are created with the ContextMenu component.
15. Briefly describe the three types of user-developed controls and how they
differ.
The three types of user-developed controls are inherited controls, user controls,
and custom controls. An inherited control derives from a standard Windows Forms
control and inherits the look, feel, and functionality of that control. User controls
allow you to combine standard Windows Forms controls and bind them together with
common functionality. Custom controls inherit from Control and are the most development-intensive
kind of control. Custom controls must implement all their own code for painting
and inherit only generic control functionality. All specific functionality must
be implemented by the developer.
16. Describe the roles of Graphics, Brush, Pen, and GraphicsPath objects in
graphics rendering.
The Graphics object represents a drawing surface and encapsulates methods that allow
graphics to be rendered to that surface. A Brush is an object that is used to fill
solid shapes, and a Pen is used to render lines. A GraphicsPath object represents
a complex shape that can be rendered by a Graphics object.
17. Describe the general procedure for rendering text to a drawing surface.
You must first obtain a reference to a Graphics object. Next, create an instance
of a GraphicsPath object. Use the GraphicsPath.AddString method to add text to the
GraphicsPath. Then, call the Graphics.DrawPath or Graphics.FillPath to render the
text.
18. Describe the role of the LicenseProvider in control licensing.
The LicenseProvider controls license validation and grants run-time licenses to
validly licensed components. The LicenseManager.Validate method checks for an available
license file and checks against the validation logic provided by the specific implementation
of LicenseProvider. You specify which LicenseProvider to use by applying the LicenseProviderAttribute.
19. Describe how to create a form or control with a nonrectangular shape.
Set the Region property of the form or control to a Region object that contains
the irregular shape. You can create a Region object from a GraphicsPath object.