55. Is it possible to enter more than one line in a TextBox control?
Yes, it is possible to enter more than one line in a TextBox control. To do this, you need to set the Multiline property of the TextBox control to True. You can set this property at design time as well as runtime. The syntax to set this property at runtime is as follows:
Textbox1.Multiline = true;
56. How can you enable a text box to change its characters format, so that users can enter password?
You can set the PasswordChar property of the TextBox class to True to enable it to accept passwords. The code to change the PasswordChar property of the TextBox class is given as follows:
textBox1.PasswordChar = ‘*';
57. What does the TickFrequency property of the TrackBar control do?
The TickFrequency property gets or sets a value that specifies the distance between ticks. By default, the distance between ticks is 1.
58. Is it possible to associate a control with more than one ContextMenu control?
No, we cannot associate a control with more than one ContextMenu control.
59. What is the difference between the Panel and GroupBox control?
The Panel and GroupBox controls both can be used as a container for other controls, such as radio buttons and check box. The main differences between a Panel and a GroupBoxcontrol are as follows:
- Panel does not display captions, while GroupBox do
- Panel has scrollbar, while GroupBox does not
60. Does a Timer control appear at run time?
Timer is a component; therefore, it does not appear at run time.
61. What is the difference between a ListBox control and a ComboBox control?
With a ListBox control, the user can only make a selection from a list of items; whereas, with a ComboBox control, the user can make a selection from the list of items as well as can add custom entry and select the same.
62. What is the function of MinDate and MaxDate properties of the MonthCalendercontrol?
The MinDate and MaxDate properties allow users to get and set the minimum and maximum allowable date.
63. Name the parent class for all Windows controls.
The Control class or System.Windows.Forms.Control class is the parent class for all Window controls.
64. What is the MaskedTextBox control? What does the Mask property do?
The MaskedTextBox control is an improvement of the TextBox control. It forces the user to provide the proper input, which is specified by the Mask property. In other words, it prevents the user to provide any invalid input to an application. The Mask property gets or sets the input type to the MaskedTextBox control. There are many built-in formats for theMask property, such as phone no., short date, time, zip code, and custom.
65. How can you adjust the height of a combo box drop-down list?
You can control the height of a combo box drop-down list by setting theMaxDropDownItems property of the combo box. The MaxDropDownItems property sets the maximum number of entries that will be displayed by the drop-down list.
66. How can you enforce a text box to display characters in uppercase?
The TextBox class contains the CharacterCasing property, which is used to specify the case of the content for a text box. This property accepts a value from the CharacterCasingenumeration of .NET Framework. The members specified in the CharacterCasingenumeration are Lower, Upper, and Normal. You can select any one of these enumerations as a value for the CharacterCasing property of a specified text box, as shown in the following code snippet:
textBox1.CharacterCasing = CharacterCasing.Upper;
67. Is it possible to associate a control with more than one ContextMenu?
No, we cannot associate a control with more than one ContextMenu.
68. How can you check/uncheck all items in the CheckedListBox control in .NET 4.0?
To check all items in .NET, you can use the following code snippet:
Code for VB:
Dim i as Integer
For i = 0 To myCheckedListBox.Items.Count - 1
myCheckedListBox.SetItemChecked(i, True)
Next
Code for C#:
for( int i = 0; i < myCheckedListBox.Items.Count; i++ )
{
myCheckedListBox.SetItemChecked(i, true);
}
69. How can we disable the context menu for a TextBox control?
The TextBox class contains the ContextMenuStrip property. When we set this property to a dummy instance of the ContextMenu class, the TextBox control is unable to provide any context menu on the right-click of the mouse.
70. How can you move and resize a control on a Windows form?
You can make use of the SetBounds() method to move as well as resize the control on a Windows form.
71. What is use of the DropDownStyle property of the ComboBox control?
The DropDownStyle property changes the style of the ComboBox control. It consists ofSimple, DropDown, and DropDownList as its values. When you select Simple, the list of items are displayed as a ListBox control. When you select DropDown, the list is displayed in a drop down style. When you select DropDownList, the list displayed in a drop down style and you cannot edit its text.
72. What is the difference between pixels, points, and em‘s when fonts are displayed?
A pixel is the lowest-resolution dot that the computer monitor supports. Its size depends on user’s settings and the size of the monitor. A point is always 1/72 of an inch. An em is the number of pixels it takes to display the letter M.
No comments:
Post a Comment