31. 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.
32. 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:
1. Normal - Represents Standard picture box behavior (the upper-left corner of the image is placed at upper-left in the picture box)
2. StretchImage - Displays image according the PictureBox size
3. AutoSize - Increases or decreases the picture size automatically as per the actual size of thePictureBox control.
4. 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
5. Zoom - Helps in stretching or shrinking the image so that it fits the PictureBox control, by maintaining the aspect ratio of the image
33. 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;
34. 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.
35. How can you place a border around a picture box?
The PictureBox control offers the BorderStyle property, which can be set to define the style of its border. This property can accept any of the three values from Fixed3D, FixedSingle, or None. These properties can be easily set through code or through the Properties window of the Visual Studio IDE.
36. How do we format numbers, dates, and currencies in a text box?
Each type has a ToString() method that can used to format date, currencies, and numbers. You can also use the String.Format() method to format these things as well. To format dates, use the ToString() member of the DateTime type.
To display panels in the StatusBar control, the ShowPanels property needs to be set to true.
32. 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:
1. Normal - Represents Standard picture box behavior (the upper-left corner of the image is placed at upper-left in the picture box)
2. StretchImage - Displays image according the PictureBox size
3. AutoSize - Increases or decreases the picture size automatically as per the actual size of thePictureBox control.
4. 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
5. Zoom - Helps in stretching or shrinking the image so that it fits the PictureBox control, by maintaining the aspect ratio of the image
33. 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;
34. 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.
35. How can you place a border around a picture box?
The PictureBox control offers the BorderStyle property, which can be set to define the style of its border. This property can accept any of the three values from Fixed3D, FixedSingle, or None. These properties can be easily set through code or through the Properties window of the Visual Studio IDE.
36. How do we format numbers, dates, and currencies in a text box?
Each type has a ToString() method that can used to format date, currencies, and numbers. You can also use the String.Format() method to format these things as well. To format dates, use the ToString() member of the DateTime type.