Master Windows Forms applications with these 30 handpicked MCQs. Dive into controls like TextBox, Label, Button, and event handling. Perfect for students and developers aiming to sharpen their VB.NET skills.
MCQs: Introduction to Forms and Controls
Creating Your First Windows Forms Application
Which namespace is primarily used for creating Windows Forms in VB.NET? a) System.Windows.Forms b) System.Windows.UI c) System.Forms.App d) System.Application.Forms
What is the default file extension for a Windows Forms project in VB.NET? a) .vbproj b) .csproj c) .wfproj d) .vbform
What is the entry point method for a Windows Forms application? a) Main() b) Start() c) Run() d) Init()
Which class is used to represent a Windows Form? a) Window b) Form c) Application d) Control
What is the primary method used to display a Windows Form? a) Show() b) Display() c) Render() d) Present()
Common Controls: TextBox, Label, Button
Which control is used to display text that cannot be edited by the user? a) TextBox b) Label c) Button d) ListBox
How do you set the initial text in a TextBox? a) TextBox.Text = “value” b) TextBox.SetText(“value”) c) TextBox.Value = “value” d) TextBox.TextField = “value”
Which event is triggered when a user clicks a Button? a) ButtonPressed b) Click c) ActionPerformed d) OnClick
What property of a Label control determines its displayed text? a) TextValue b) LabelText c) Text d) Content
What is the default behavior of the Tab key in a TextBox? a) Moves to the next TextBox b) Inserts a tab character c) Does nothing d) Triggers an event
Handling Events (Click, TextChanged)
Which method is used to handle the Click event of a Button? a) AddHandler b) AssignEvent c) SetHandler d) HandleEvent
What is the default signature of a Click event handler? a) Private Sub Button_Click() b) Public Sub ButtonClick(ByVal sender As Object) c) Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs) d) Private Function ButtonClick(ByVal sender As Object, ByVal e As EventArgs)
The TextChanged event is fired when: a) A Button is clicked b) The text of a control changes c) A form is resized d) A control is focused
How do you attach an event handler to a control in code? a) Control.Event = AddressOf HandlerMethod b) AddHandler Control.Event, AddressOf HandlerMethod c) SetHandler(Control.Event, HandlerMethod) d) AttachEvent(Control.Event, HandlerMethod)
What is the main purpose of the TextChanged event in a TextBox? a) Monitor text input dynamically b) Detect form submission c) Validate form data d) Trigger on focus change
Advanced Topics on Controls
Which property determines if a control is visible to the user? a) Enabled b) Visible c) Displayed d) Shown
How can you disable user interaction with a Button? a) Set Enabled to False b) Set Active to False c) Set Usable to False d) Set Available to False
What property of a TextBox sets a password character mask? a) TextMask b) MaskChar c) PasswordChar d) HiddenChar
What does the Anchor property of a control define? a) The control’s docking position b) The control’s resizing behavior c) The control’s alignment d) The control’s visibility
Which property of a Label enables multiline text display? a) Multiline b) WrapText c) AutoSize d) WordWrap
General Questions on Forms and Controls
What is the function of the Dock property in a control? a) Adjust size based on parent container b) Align control to the form edges c) Fix position on the form d) Handle focus priority
What event is triggered when a form is closed? a) Closing b) FormClosed c) End d) Dispose
Which property sets the title of a form? a) Title b) Caption c) Text d) Header
How can you programmatically close a Windows Form? a) Form.Close() b) Form.End() c) Form.Terminate() d) Form.Dispose()
What property is used to control the transparency of a form? a) TransparentValue b) Opacity c) AlphaLevel d) Transparency
How do you make a TextBox read-only? a) Set ReadOnly to True b) Set Editable to False c) Set Lock to True d) Set Writable to False
Which event is triggered when a form is loaded? a) Initialize b) Load c) FormLoad d) Activated
How do you add a tooltip to a control? a) Use the Tooltip property b) Attach a ToolTip component c) AddHandler Tooltip.Text d) Set Hint property
What does the AutoSize property do for a Label? a) Automatically adjusts the size to fit the text b) Resizes based on parent container c) Locks the current size d) Dynamically changes font size
Which control would you use for accepting multiline text input? a) TextBox with Multiline enabled b) Label with WrapText enabled c) RichTextBox d) Both a and c
Answers Table
Qno
Answer (Option with Text)
1
a) System.Windows.Forms
2
a) .vbproj
3
a) Main()
4
b) Form
5
a) Show()
6
b) Label
7
a) TextBox.Text = “value”
8
b) Click
9
c) Text
10
a) Moves to the next TextBox
11
b) AddHandler
12
c) Private Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
13
b) The text of a control changes
14
b) AddHandler Control.Event, AddressOf HandlerMethod