32. What is the difference between the Add() and Insert() methods of a ListBox control?
The Add() method simply adds an item into the list box; whereas, the Insert() method inserts an item at the specified index.
33. Consider a situation where you have added panels in a StatusBar control; however, they are not displayed at run time. What could be the reason for this?
To display panels in the StatusBar control, the ShowPanels property needs to be set to true.
34. What is the function of the SizeMode property of the PictureBox control?
The SizeMode property determines how the picture will be displayed in the PictureBox control. The following five enumerations are used to set the value of the SizeMode property:
Normal – Represents Standard picture box behavior (the upper-left corner of the image is placed at upper-left in the picture box)
StretchImage – Displays image according the PictureBox size
AutoSize – Increases or decreases the picture size automatically as per the actual size of thePictureBox control.
CenterImage – Displays the image in the center if it is smaller than the PictureBox control; otherwise, the center part of the image is placed in the PictureBox control and its outside edges are clipped
Zoom – Helps in stretching or shrinking the image so that it fits the PictureBox control, by maintaining the aspect ratio of the image
35. How can you prevent users of an application from editing the text in the ComboBox controls in .NET 4.0?
The ComboBox class contains the DropDownStyle property, which is used to define the display style of the items in the ComboBox control. The DropDownStyle property accepts a value from the ComboBoxStyleenumeration, which contains three members to define the styles for the items: Simple, DropDownList, andDropDown. The DropDownList value of the ComboBoxStyle enumeration is selected to set a ComboBox control as non-editable by users, as shown in the following code snippets:
Code for VB:
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Code for C#:
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
36. Which class manages the event and layout of all ToolStrip elements?
The ToolStripItem class manages the event and layout of all elements that the ToolStrip control contains.