• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/73

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

73 Cards in this Set

  • Front
  • Back
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.
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.
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.
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.
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.
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.
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;
}
}
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.
How can you programmatically position the cursor on a given line or on a character in the RichTextBox control 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);
}
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.
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.
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_LBUTTONDOWN and WM_LBUTTONDBLCLK events.
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.
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;
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 your RichTextBox value to a RTF (Rich Text Format) file and load value of RTF file to the RichTextBox control.
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.
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.
How do you create a separator in the Menu Designer?
You can use hyphen (-) to create a separator.
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.
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.
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.
What does the PerformStep() method do?
The PerformStep() method increases the value of Progress bar according to the amount set by the Step property.
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.
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.
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.
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.
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.
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 TransparencyKey property 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.
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.
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).
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.
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.
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.
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 the PictureBox 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
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 ComboBoxStyle enumeration, which contains three members to define the styles for the items: Simple, DropDownList, and DropDown. 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;
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.
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.
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.
What is the use of the Panel control? Does it display at runtime?
Panels acts as a container to group other controls. It is an important control, when you want to show/hide a group of controls and relocate a number of controls simultaneously.
When you generate a new control at runtime, it works as a container control. As we know, it is a container control; therefore, it is not displayed at runtime.
Is it possible to add an image on the RadioButton control?
Yes, you can add an image on the RadioButton control by setting the Image property.
What is the use of a toolstrip container?
A toolstrip container is used to contain controls, such as ToolStrip, MenuStrip, and StatusStrip, so that these controls can be docked and moved at the run time.
Name the methods, available in .NET 4.0, that are used to add and delete items from a ListBox control?
The following methods can be used to add and delete items from a ListBox control. The Items.Add() and Items.Insert() methods are used to add items; whereas, the Items.Remove(), Items.RemoveAt(), and Items.Clear() methods are used to delete items from a ListBox control.
What is the importance of a Button control?
A Button control is an important Windows control, which provides the most common way of creating and handling an event in the code with the help of its Click event.
How can you unselect the selected items in a ListView control programmatically in .NET 4.0?
The syntax to unselect the selected items in the ListView control is shown in the following code snippets:
Code for VB:
Me.listView1.SelectedItems.Clear()
Code for C#:
this.listView1.SelectedItems.Clear();
How can you get the text of the RichTextBox control, including all rich text format strings in .NET 4.0?
The Rtf property of the RichTextBox control is used to set or get texts, including the RTF format code.
What is the use of a Timer control? Can a Timer control pause?
The Timer control is a mechanism to perform an iterative task at a specified time interval. You cannot pause it because it can only start and stop.
What is die difference between a CheckBox control and a RadioButton control?
A CheckBox control is square shaped; whereas, a RadioButton control is round in shape. Moreover, you can select more than one CheckBox control from a group of CheckBox controls; whereas, you can select only a single RadioButton control from a group of RadioButton controls.
Can you write a class without specifying a namespace? Which namespace does it belong to by default?
Yes, we can write a dass without specifying namespace and that class belongs to a global namespace that has no name.
What are the three states set in the CheckState property of CheckBox?
Checked
Unchecked
Indeterminate
How can you display an icon at runtime on the StatusStrip control?
The following code snippet shows the code to display an icon at runtime on the StatusStrip control:
toolStripStatusLabel2.Image = Bitmap.FromFile("D:\\Indiabix\\Images\\1.bmp");
Can you add more than one item simultaneously in the ListBox control?
Yes, You can add more than one item simultaneously in the ListBox control by using the AddRange() method.
What is the difference between a MenuStrip control and a ContextMenuStrip control?
The difference between a MenuStrip control and a ContextMenuStrip control is that a MenuStrip control is associated with the Windows Form; whereas, a ContextMenuStrip control is associated with a control, which is added to the Windows Form.
What are the values that can be assigned to the DialogResult property of a Button control?
The DialogResult property of a Button control can be assigned a value from the DialogResult enumerations, which are as follows:
Abort-Returns Abort
Cancel-Returns Cancel
Ignore-Returns Ignore
No-Returns No
None-Nothing is returned from the dialog box
OK-Returns OK
Retry-Returns Retry
Yes-Returns Yes
Why do you require user-defined controls?
User-defined controls are particularly useful in situations where you need to enhance the functionality of an existing control.
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;
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 = '*';
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.
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.
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 GroupBox control are as follows:
Panel does not display captions, while GroupBox do
Panel has scrollbar, while GroupBox does not
Does a Timer control appear at run time?
Timer is a component; therefore, it does not appear at run time.
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.
What is the function of MinDate and MaxDate properties of the MonthCalender control?
The MinDate and MaxDate properties allow users to get and set the minimum and maximum allowable date.
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.
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 the Mask property, such as phone no., short date, time, zip code, and custom.
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 the MaxDropDownItems property of the combo box. The MaxDropDownItems property sets the maximum number of entries that will be displayed by the drop-down list.
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 CharacterCasing enumeration of .NET Framework. The members specified in the CharacterCasing enumeration 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;
Is it possible to associate a control with more than one ContextMenu?
No, we cannot associate a control with more than one ContextMenu.
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);
}
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.
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.
What is use of the DropDownStyle property of the ComboBox control?
The DropDownStyle property changes the style of the ComboBox control. It consists of Simple, 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.
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.