Container Controls

Panel, GroupBox और TabControl दूसरे controls hold करते हैं और एक unit की तरह move होते हैं, और containers radio-button groups define करते हैं: 2 sets के RadioButtons को 2 containers चाहिए वरना वे एक में merge हो जाते हैं।

9 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

वे Radio Buttons जो आपस में लड़ते थे

ShopKeeper में 2 sets के choices बढ़ते हैं: payment mode (Cash/Card/UPI) और delivery (Take away/Home delivery)। आप सारे 5 RadioButtons सीधे form पर drop करते हैं और run करते हैं।

Card click कीजिए। अब Home delivery click कीजिए... और Card चुपचाप खुद को deselect कर देता है। 2 questions आपस में कुश्ती कर रहे हैं: FIVE में से एक बार में सिर्फ़ एक button select हो सकता है।

Buttons में कुछ ग़लत नहीं है। इनके आस-पास कुछ missing है, और वह कुछ यही lesson है।

Theory

Counter पर Trays

एक shop counter जिस पर coins, notes और receipts ढीले पड़े हों chaos है; हर तरह की चीज़ को एक tray में डालिए और अचानक आप पूरी tray को एक साथ उठा, move या lock कर सकते हैं।

एक container control controls के लिए एक tray है: children इसके अंदर रहते हैं, इसके साथ move करते हैं, इसके साथ disable होते हैं। और एक tray की तरह, यह एक शांत सवाल का भी answer देता है: कौन सी items एक साथ belong करती हैं, जो exactly वही है जो उन radio buttons को सुनना ज़रूरी था।

Theory

3 Containers, Formally

  • Panel: एक plain rectangle जो children hold करता है; कोई caption नहीं। इसकी AutoScroll property scrollbars जोड़ती है जब children overflow करें: लंबे forms के लिए अच्छा।
  • GroupBox: caption WALA एक border (इसकी Text property)। एक group को label करने का standard तरीका: "Payment mode"।
  • TabControl: TabPages का एक stack, file dividers जैसा: ShopKeeper को 3 अलग windows के बिना Billing, Day Report और Settings tabs मिलते हैं।

Collective behaviour ही point है: एक container का Enabled False set कीजिए और अंदर हर child साथ में grey हो जाता है।

Theory

Containers Radio Groups Define करते हैं

यहाँ वह rule है जिस पर hook ने trip किया:

RadioButtons अपने container के अंदर mutually exclusive हैं। एक container share करने वाले सारे radios ONE group बनाते हैं; इन सबमें से एक selection।

Fix 2 trays है: Payment mode caption वाला एक GroupBox जिसमें rdoCash, rdoCard, rdoUPI हों, और Delivery caption वाला दूसरा GroupBox जिसमें rdoTakeAway, rdoHome हों। अब Card और Home delivery coexist करते हैं, क्योंकि हर group अपनी election privately settle करता है।

Quiz

एक form पर 5 RadioButtons सीधे placed हैं: 3 payment के लिए, 2 delivery के लिए। Observed behaviour क्या है?

  1. Payment और delivery independently काम करते हैं: VB.NET इन्हें name prefix से group करता है
  2. सारे 5 एक exclusive group बनाते हैं: कोई भी button select करना बाकी 4 को deselect कर देता है
  3. Compile error: RadioButtons बिना GroupBox के placed नहीं हो सकते
  4. सिर्फ़ पहले 3 placed buttons काम करते हैं; बाकी ignore हो जाते हैं
Show the answer

सारे 5 एक exclusive group बनाते हैं: कोई भी button select करना बाकी 4 को deselect कर देता है

Form खुद एक बड़ा container है, तो हर directly-placed radio एक merged group join करता है: Home delivery चुनना Card को deselect करता है, exactly hook का bug। Option A एक naming convention invent करता है जो exist नहीं करता; grouping containment follow करती है, नाम कभी नहीं। Option C false है: form एक perfectly legal container है, बस यहाँ ग़लत वाला। Option D placement-order rules invent करता है। Exam के लिए एक sentence में fix: RadioButtons के हर logical group को अपने container में रखिए, usually एक GroupBox।

Think first

Tray चुनिए

तीन needs: (1) payment radios के चारों तरफ़ एक labelled box, (2) 40-item stock list के लिए एक scrollable area, (3) एक window में Billing और Settings को अलग screens की तरह। Tap करने से पहले Panel, GroupBox और TabControl assign कीजिए।

Show the answer

(1) GroupBox: यह 3 में से इकलौता है जिसके पास built-in caption है, और labelled radio groups इसका signature job हैं। (2) AutoScroll = True वाला Panel: plain, uncaptioned, children overflow करने पर scroll करता है। (3) TabControl: एक window, कई TabPages, अलग forms की कोई juggling नहीं। Internalise करने लायक pattern: caption चाहिए = GroupBox, scrolling चाहिए = Panel, sections चाहिए = TabControl।

Watch out

Container Slips जो Time खा जाते हैं

एक control को GroupBox के अंदर की जगह उसके NEAR drop करना: यह अंदर जैसा दिखता है पर form का होता है; इसके radios तब form के group में join होते हैं और bug वापस आ जाता है। तब तक drag कीजिए जब तक container highlight न हो, और container move करके verify कीजिए: असली children इसके साथ move करते हैं।

Container delete करना इसके children delete करता है: पहले controls को बाहर lift कीजिए।

Z-order confusion: एक control के बाद बना Panel इसके ऊपर बैठ सकता है; right-click, Send to Back।

Theory

Containers Structure हैं, Decoration नहीं

Beginners GroupBoxes को cosmetic borders की तरह देखते हैं। Professionals containment को LOGIC की तरह इस्तेमाल करते हैं: radio grouping, collective enable/disable (पूरे payment section को तब तक lock कीजिए जब तक items exist न करें: grpPayment.Enabled = False, एक line), और layout जो resizing survive करता है। BCA402-02 का UI/UX subject इस principle को proximity नाम देगा: related things visibly साथ belong करती हैं। अगला lesson till को इसकी सबसे important tray देता है: bill दिखाने वाला DataGrid, एक DataSet से feed होते हुए।

Summary

Key takeaways

  • Containers child controls hold करते हैं: container को move, hide या disable कीजिए और children साथ चलते हैं।
  • Panel = plain + AutoScroll; GroupBox = captioned border; TabControl = sections की तरह TabPages।
  • RadioButtons PER CONTAINER exclusive हैं: एक container, एक group, एक selection।
  • दो independent radio groups को 2 containers (GroupBoxes) चाहिए, वरना वे एक लड़ते हुए group में merge हो जाते हैं।
  • Controls को एक container में सिर्फ़ ऊपर नहीं, अंदर (highlight देखते हुए) drop कीजिए।
  • एक container पर collective Enabled/Visible एक-line section locking है।
  • Memory hook: tray decide करती है election में कौन है।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Introduction to Windows controls

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Container Controls · .NET Programming · Gri-Learn