Theory
The radio buttons that fought each other
ShopKeeper grows 2 sets of choices: payment mode (Cash/Card/UPI) and delivery (Take away/Home delivery). You drop all 5 RadioButtons straight onto the form and run.
Click Card. Now click Home delivery... and Card quietly deselects itself. The 2 questions are wrestling: only one button of the FIVE can be selected at a time.
Nothing is wrong with the buttons. Something is missing around them, and that something is this lesson.
Theory
Trays on the counter
A shop counter with coins, notes and receipts loose on it is chaos; put each kind in a tray and suddenly you can lift, move or lock away a whole tray at once.
A container control is a tray for controls: children live inside it, move with it, disable with it. And like a tray, it also answers a quieter question: which items belong together, which is exactly what those radio buttons needed to hear.
Theory
The 3 containers, formally
- Panel: a plain rectangle that holds children; no caption. Its AutoScroll property adds scrollbars when children overflow: good for long forms.
- GroupBox: a border WITH a caption (its Text property). The standard way to label a group: "Payment mode".
- TabControl: a stack of TabPages, like file dividers: ShopKeeper gets Billing, Day Report and Settings tabs without 3 separate windows.
Collective behaviour is the point: set a container's Enabled to False and every child inside goes grey together.
Theory
Containers define radio groups
Here is the rule the hook tripped over:
RadioButtons are mutually exclusive within their container. All radios sharing one container form ONE group; one selection among them all.
The fix is 2 trays: a GroupBox captioned Payment mode holding rdoCash, rdoCard, rdoUPI, and a second GroupBox captioned Delivery holding rdoTakeAway, rdoHome. Now Card and Home delivery coexist, because each group settles its own election privately.
Quiz
A form has 5 RadioButtons placed directly on it: 3 for payment, 2 for delivery. What is the observed behaviour?
- Payment and delivery work independently: VB.NET groups them by name prefix
- All 5 form one exclusive group: selecting any button deselects the other 4
- Compile error: RadioButtons cannot be placed without a GroupBox
- Only the first 3 placed buttons work; the rest are ignored
Show the answer
All 5 form one exclusive group: selecting any button deselects the other 4
The form itself is one big container, so every directly-placed radio joins one merged group: choosing Home delivery deselects Card, precisely the hook's bug. Option A invents a naming convention that does not exist; grouping follows containment, never names. Option C is false: the form is a perfectly legal container, just the wrong one here. Option D invents placement-order rules. Fix in one sentence for the exam: put each logical group of RadioButtons in its own container, usually a GroupBox.
Think first
Pick the tray
Three needs: (1) a labelled box around the payment radios, (2) a scrollable area for a 40-item stock list, (3) Billing and Settings as separate screens in one window. Assign Panel, GroupBox and TabControl before tapping.
Show the answer
(1) GroupBox: it is the only one of the 3 with a built-in caption, and labelled radio groups are its signature job. (2) Panel with AutoScroll = True: plain, uncaptioned, scrolls when children overflow. (3) TabControl: one window, multiple TabPages, no juggling of separate forms. The pattern to internalise: caption wanted = GroupBox, scrolling wanted = Panel, sections wanted = TabControl.
Watch out
Container slips that cost time
Dropping a control NEAR a GroupBox instead of IN it: it looks inside but belongs to the form; its radios then join the form's group and the bug returns. Drag until the container highlights, and verify by moving the container: true children move with it.
Deleting a container deletes its children: lift the controls out first.
Z-order confusion: a Panel drawn after a control can sit ON TOP of it; right-click, Send to Back.
Theory
Containers are structure, not decoration
Beginners see GroupBoxes as cosmetic borders. Professionals use containment as LOGIC: radio grouping, collective enable/disable (lock the whole payment section until items exist: grpPayment.Enabled = False, one line), and layout that survives resizing. BCA402-02's UI/UX subject will name this principle proximity: related things belong visibly together. Next lesson the till gets its most important tray of all: the DataGrid showing the bill, fed by a DataSet.
Summary
Key takeaways
- Containers hold child controls: move, hide or disable the container and children follow.
- Panel = plain + AutoScroll; GroupBox = captioned border; TabControl = TabPages as sections.
- RadioButtons are exclusive PER CONTAINER: one container, one group, one selection.
- Two independent radio groups need 2 containers (GroupBoxes), or they merge into one fighting group.
- Drop controls INTO a container (watch the highlight), not merely on top of it.
- Collective Enabled/Visible on a container is one-line section locking.
- Memory hook: the tray decides who is in the election.