13. What is the function of the CheckState property of the CheckBox control?
The CheckState property gets or sets the state of CheckBox.
If the ThreeState property is set to false, the CheckState property value can only be set toCheckState.Indeterminate in code and not by user interaction.
Checked – The CheckBox displays a check mark. The control appears sunken.
Unchecked – The CheckBox is empty. The control appears raised.
Indeterminate – The CheckBox displays a check mark and is shaded.
Unchecked – The CheckBox is empty. The control appears raised.
Indeterminate – The CheckBox displays a check mark and is shaded.
14. Write a code to select an item in the ListView control programmatically in C#?
To select an item from the ListView control, you can use the following code snippet:
//Make sure the listview has focus
listview1.Focus();
listview1.Items[i].Selected = true;
15. Differentiate between a TextBox control and RichTextBox control.
The TextBox control is an input control, which allows a user to enter text to an application at runtime. By default, it allows only single line text; however, you can change its property to accept the multiline text as well as scroll bar also.
The RichTextBox control is similar to the TextBox control with the difference that it allows the user to format its text also. You can format the text in various ways, such as bold,italic, and underlined as well as change its color and font. You can save yourRichTextBox value to a RTF (Rich Text Format) file and load value of RTF file to theRichTextBox control.
16. Describe the ToolTip control. How can you associate it with other controls?
The ToolTip control generates a small pop-up window with explanatory text for an element It is displayed when the user pauses the mouse for a certain period over an element/control. Tool tips provide a quick help to user to understand about that element. To associate a tool tip with other control, you need to implement the SetToolTip() method.
17. What does the DialogResult property of a Button control do?
The DialogResult property retrieves or sets a value that is returned to the parent form when the button is clicked.
18. How do you create a separator in the Menu Designer?
You can use hyphen (-) to create a separator.
19. Define the TrackBar control.
The TrackBar control, also known as the slider control, works as a navigator to display a large amount of information or for visual adjustment of numeric setting. There are two parts in a TrackBar control – thumb (also known as slider) and tick marks. The thumb part acts as a slider. You can adjust the thumb part using the Value property. The tick marks are visual indicators that are spaced at regular intervals.
20. How does an MDI form differ from a standard form?
An MDI form closely resembles a standard form with one major difference-the client area of an MDI form acts as a container for other forms. It means that an MDI form, also known as an MDI parent form, can display MDI child forms inside it.
21. Which method provides the functionality to display a dialog box at runtime?
The ShowDialog() method is used to display the dialog box at run time.
22. What does the PerformStep() method do?
The PerformStep() method increases the value of Progress bar according to the amount set by the Step property.
23. Write a method to get only the name of a file from the complete path string in C#.
Use a FileInfo class and instantiate its object with the full path as the constructor argument and then simply call the FileInfo.Name file and you will get just the name of the file.
24. What does the OpenFile() method of the OpenFileDialog control do?
The OpenFile() method opens the file selected by the user with read-only permission. The file is specified by the FileName property.
25. How do you retrieve the customized properties of a .NET application from the XML .config file?
Initialize an instance of the AppSettingsReader class. Call the GetValue() method of theAppSettingsReader class, passing in the name of the property and the type expected. Finally, assign the result to the appropriate variable.
26. What is the difference between a toolstrip drop-down button and a toolstrip split button?
The difference between a toolstrip drop-down button and a toolstrip split button is that a toolstrip split button is a combination of two controls – a push button and a drop-down button; whereas, a toolstrip drop-down button is a single control.
27. Which event of a TextBox control helps in restricting a text box from accepting numeric digits in .NET 4.0?
The KeyPress event of a text box is used to restrict it from accepting numeric digits or any other character.
28. How would you create an ellipse, which is a non- rectangular window?
Open a new Windows form, which is by default rectangular in design and then set theTransparencyKey property to the same value as BackColor, which will effectively make the background of the form transparent. Then, set the FormBorderStyle property toFormBorderStyle.None, which removes the contour and contents of the form.
29. What does the Checked property of the DateTimePicker control do?
The Checked property holds either true or false value. It holds true, when the Value property hold a valid date-time value and is updatable; otherwise, false.
30. Name the classes used to handle standard menu in a MenuStrip control.
The two main classes used to handle standard menu in a MenuStrip control are:
- MenuStrip – Acts as a container for the menu structure of a form.
- ToolStripMenuItem – Supports the items in a menu system (including the menus, such as File and Edit).
No comments:
Post a Comment