Interview Preparation Exam  >  Interview Preparation Notes  >  Placement Papers - Technical & HR Questions  >  Windows Controls (Part - 1), .NET Interview Questions

Windows Controls (Part - 1), .NET Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation PDF Download

1. How can we auto size a button to fit its text?

The Button control has the AutoSize property, which can be set to true or false. If we set the value of the AutoSize property to true, then the button control automatically alters its size according to the content displayed on it.


2. How can we display an icon or a bitmap image on the Button control?

The Button class contains the Image property, which is used to set an image on the Button control. We can also set the alignment of the image by using the ImageAlign property of the Button class.


3. Which method is used to generate the click event of the Control class for the Button control in C#?

The PerformClick() method of the Button class is used to generate the Click event of the System.Windows.Forms.Control class.


4. A Windows Form will not show the Minimize, Maximize, and Close buttons, if the ControlBox property of the form is set to False. (True/False)

True.


5. How is anchoring different from docking?

Docking refers to attaching a control to either an edge (top, right, bottom, or left) or the client area of the parent control. On the other hand, anchoring is a process in which you need to specify the distance that each edge of your control maintains from the edges of the parent control.


6. How can you display a default value in the text box of an input box?

You can display a default value in the text box of an input box by using the DefaultResponse argument of the InputBox() function.


7. How will you pick a color from the ColorDialog box?

To pick a color from the color dialog box, you need to create an instance of the ColorDialog box and invoke to the ShowDialog() method. The code to display the color dialog box and set the BackColor property of the Label control similar to the color selected in the color dialog box control is:
 

private void button1_Click(object sender, EventArgs e)
{
 if (colorDialog1.ShowDialog() != DialogResult.Cancel)
 {
 label1.Text = "Here's my new color!";
 label1.BackColor = colorDialog1.Color; 
 }
}

 

8. How can you get or set the time between Timer ticks?

There is an Interval property, which is responsible to get and set the time in milliseconds.


9. How can you programmatically position the cursor on a given line or on a character in the RichTextBoxcontrol in C#?

The RichTextBox control contains the Lines array property, which displays one item of an array in a separate line. Each line entry has a Length property, which can be used to accurately position the cursor at a character, as shown in the following code snippet:
 

private void GoToLineAndColumn(RichTextBox RTB, int Line, int Column)
{
 int offset = 0;
 for(int i = 0; i < Line -1 && i < RTB.Lines.Length; i++)
 {
 offset += RTB.Lines[i].Length + 1;
 }
 RTB.Focus();
 RTB.Select(offset + Column, 0);
}


10. What is the difference between the WindowsDefaultLocation and WindowsDefaultBounds properties?

The WindowsDefaultLocation property makes the form to start up at a location selected by the operating system, but with internally specified size. The WindowsDefaultBounds property delegates both size and starting position choices to the operating system.


11. Where does an ImageList control appear when you add it at the design time?

The ImageList control is a component; therefore, it appears in the component tray at the design time.


12. How can you programmattically prevent a Combobox from dropping, in .NET 4.0?

To avoid dropping of a Combobox, you need to override the WndProc() method and ignore WM_LBUTTONDOWNand WM_LBUTTONDBLCLK events.


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 to CheckState.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.


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 bolditalic, and underlined as well as change its color and font. You can save your RichTextBox value to a RTF (Rich Text Format) file and load value of RTF file to the RichTextBox 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 Stepproperty.


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 the AppSettingsReader 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 the TransparencyKeyproperty to the same value as BackColor, which will effectively make the background of the form transparent. Then, set the FormBorderStyle property to FormBorderStyle.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).

 

31. How can you attach a horizontal scroll bar with the ListBox control?

You need to set the the MultiColumn property of the ListBox control to True to attach a horizontal scroll bar with it.


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:

  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 the PictureBox 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
The document Windows Controls (Part - 1), .NET Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation is a part of the Interview Preparation Course Placement Papers - Technical & HR Questions.
All you need of Interview Preparation at this link: Interview Preparation
85 docs|57 tests

Top Courses for Interview Preparation

85 docs|57 tests
Download as PDF
Explore Courses for Interview Preparation exam

Top Courses for Interview Preparation

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

ppt

,

shortcuts and tricks

,

mock tests for examination

,

Summary

,

.NET Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

past year papers

,

study material

,

Extra Questions

,

Exam

,

Important questions

,

Sample Paper

,

video lectures

,

Objective type Questions

,

.NET Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

Viva Questions

,

practice quizzes

,

.NET Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

MCQs

,

pdf

,

Windows Controls (Part - 1)

,

Free

,

Windows Controls (Part - 1)

,

Windows Controls (Part - 1)

,

Semester Notes

,

Previous Year Questions with Solutions

;