Theory
Till Design कीजिए, Control by Control
खुद को Mehta Stores के counter पर रखिए और list कीजिए billing screen को क्या चाहिए:
एक title (सिर्फ़ displayed), item name type करने के लिए एक box, quantity सिर्फ़ digits की तरह typed, Cash/Card/UPI में से ONE payment mode picked, शायद ऊपर एक carry-bag added, bill की date, एक Add button, और day report बनते हुए एक progress bar।
उस list की हर need exactly एक Toolbox control पर map होती है। यह lesson वह map है, और एक pattern सारे 17 को learnable बनाता है।
Formula
3-Part Pattern (एक बार सीखिए, 17 बार Apply कीजिए)
हर control same deal है:
- Properties: इसकी settings (Text, Checked, Value, Items)
- Events: यह क्या announce करता है (Click, TextChanged, CheckedChanged)
- Methods: आप इसे क्या order कर सकते हैं (Focus(), Items.Add())
तो "TextBox सीखिए" का मतलब है: key property Text, key event TextChanged। हर control question को इसी shape में answer कीजिए और marks follow करते हैं।
At a glance
Everyday Eight
| Control | Till पर Job | Key Property | Key Event |
|---|---|---|---|
| Label | Display-only text (shop का नाम) | Text | (शायद ही कभी handled) |
| TextBox | Item का नाम type कीजिए | Text | TextChanged |
| Button | Item add कीजिए, bill print कीजिए | Text | Click |
| CheckBox | Any-of extras (carry bag) | Checked | CheckedChanged |
| RadioButton | 3 में से ONE payment mode | Checked | CheckedChanged |
| ComboBox | एक unit चुनिए (kg/pkt/pc) | SelectedItem, Items | SelectedIndexChanged |
| ListBox | एक visible list से चुनिए | Items, SelectedIndex | SelectedIndexChanged |
| DateTimePicker | Bill की date | Value | ValueChanged |
At a glance
Specialists
| Control | Specialty | इसे याद रखने का तरीका |
|---|---|---|
| MaskedTextBox | Typing को एक pattern में force किया गया | 10-digit phone के लिए Mask = "0000000000" |
| ProgressBar | Long task feedback | Minimum, Maximum, Value |
| PictureBox | एक image दिखाता है | Image, SizeMode |
| RichTextBox | Formatted text (bold, colour) | typography वाला एक TextBox |
| TreeView | Hierarchies (category > item) | Nodes |
| ToolTip | किसी दूसरे control पर hover hint | SetToolTip(btnAdd, "Adds to bill") |
| NotifyIcon | System tray में रहता है | Till minimised रहते हुए भी चलता रहता है |
| LinkLabel | Clickable link text | LinkClicked |
| CheckedListBox | एक list जहाँ हर row में एक checkbox है | CheckedItems |
Practical
Add Button, Controls पढ़ते हुए
Private Sub btnAdd_Click(sender As Object, e As EventArgs) _
Handles btnAdd.Click
Dim item As String = txtItem.Text
Dim qty As Integer = CInt(txtQty.Text)
Dim mode As String = "Cash"
If rdoCard.Checked Then mode = "Card"
If rdoUPI.Checked Then mode = "UPI"
If chkBag.Checked Then qty += 1 ' carry bag added
lblStatus.Text = item & " x" & qty & " (" & mode & ") on " & _
dtpBill.Value.ToString("dd/MM/yyyy")
End Sub
Quiz
Customer को exactly ONE payment mode चुनना ज़रूरी है, और Mehta Uncle चाहते हैं सारे 3 options एक नज़र में visible हों। कौन सा control fit करता है?
- Cash, Card, UPI labelled तीन CheckBoxes
- Cash, Card, UPI labelled तीन RadioButtons
- एक TextBox जहाँ cashier mode type करे
- तीन Buttons, हर mode के लिए एक
Show the answer
Cash, Card, UPI labelled तीन RadioButtons
RadioButtons exactly-one-of-few के लिए BUILT हैं: एक select करना automatically इसके siblings को deselect कर देता है, और सारे options visible रहते हैं। CheckBoxes independent हैं, तो Cash AND Card दोनों ticked हो सकते थे: checkboxes का मतलब any-of है, radios का one-of, वह distinction जिसे drill करने के लिए यह question exist करता है। एक TextBox typos invite करता है ("cassh") और validation pain। Buttons choice याद रखने के बजाय actions fire करते हैं; click के बाद, screen पर कुछ नहीं दिखाता कौन सा mode selected है। एक ComboBox भी one-of enforce करता, पर options को एक click के पीछे hide करता, visible-at-a-glance requirement fail करते हुए।
Think first
Alphabet को Quantity Box तक पहुँचने से रोकिए
Quantity सिर्फ़ digits होनी चाहिए, और phone numbers exactly 10 digits। एक plain TextBox "abc" happily accept कर लेता है। Specialists table scan कीजिए: कौन सा control इसे TYPING stage पर fix करता है, और कैसे?
Show the answer
MaskedTextBox, इसकी Mask property के ज़रिए: Mask = "0000000000" exactly 10 digits accept करता है और typed होते ही letters को physically refuse करता है; कोई validation code नहीं, कोई error message नहीं चाहिए, क्योंकि ग़लत input कभी अंदर आ ही नहीं सकता। इसके पीछे का design lesson: best validation एक ऐसा control है जो invalid input को impossible बना दे, Unit 2 के Enum idea का UI cousin। उन rules के लिए जिन्हें एक mask express नहीं कर सकता (price positive होना चाहिए), आप अभी भी code में validate करते हैं, और 3 lessons आगे वाला ErrorProvider component polite तरीका दिखाएगा।
Watch out
तीन Control-Picking Mistakes
CheckBox जहाँ RadioButton belong करता है: any-of बनाम one-of; Cash और Card दोनों से paid एक bill designer में born हुआ एक data bug है।
TextBox.Text हमेशा एक String है: arithmetic से पहले CInt(txtQty.Text), Unit 2 के InputBox जैसा exactly; "2" & 3, 5 नहीं है।
Space से ListBox बनाम ComboBox: same idea (Items से चुनना); ListBox list को permanently दिखाता है, ComboBox इसे fold away करता है। सिर्फ़ look से choose करना, बिना WHY बताए, reasoning mark drop करता है।
Theory
किसी भी नए Control को 30 Seconds में पढ़िए
Pattern इस syllabus से आगे भी generalise होता है: किसी भी unfamiliar control से मिलिए, VB.NET में या Android में (BCA305-02 के widgets same deal थे), और 3 questions पूछिए: इसकी key properties क्या हैं? यह कौन से events raise करता है? कौन से methods matter करते हैं? Properties window पहले 2 का directly answer देती है (इसका lightning-bolt tab events list करता है)। अगला lesson: वे containers जो इन controls को group करते हैं, और उस topic के अंदर छुपा radio-button surprise।
Summary
Key takeaways
- हर control = properties (settings) + events (announcements) + methods (orders)।
- Core mapping: Label display करता है, TextBox types लेता है, Button click होता है, DateTimePicker dates लेता है।
- Choices: CheckBox = any-of (independent); RadioButton = exactly-one-of; ComboBox/ListBox = Items से pick।
- Specialists: MaskedTextBox एक typing pattern force करता है, ProgressBar Minimum और Maximum के बीच Value दिखाता है, ToolTip hover hints attach करता है, NotifyIcon tray में बैठता है।
- TextBox.Text एक String है: arithmetic से पहले convert कीजिए।
- बाद में scold करने वाले code से बेहतर वे controls हैं जो invalid input को impossible बना दें।
- Memory hook: radios एक चुनते हैं, checks कई चुनते हैं, combos एक list से चुनते हैं।