Container Controls

Panel, GroupBox અને TabControl બીજા controls ને hold કરે છે અને એક unit તરીકે move થાય છે, અને containers radio-button groups ને define કરે છે: 2 sets of RadioButtons ને 2 containers જોઈએ છે અથવા તેઓ એક માં merge થઈ જાય છે.

9 min read · 9 cards · 2 checks

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


Theory

radio buttons જે એકબીજા સાથે fought કર્યા

ShopKeeper 2 sets of choices ને grow કરે છે: payment mode (Cash/Card/UPI) અને delivery (Take away/Home delivery). તમે બધા 5 RadioButtons ને સીધા form પર drop કરો છો અને run કરો છો.

Card પર click કરો. હવે Home delivery પર click કરો... અને Card quietly deselect થઈ જાય છે. 2 questions wrestling કરે છે: FIVE માંથી માત્ર એક button એક સમયે selected થઈ શકે છે.

buttons માં કંઈ wrong નથી. તેમની આસપાસ કંઈક missing છે, અને તે something એ આ lesson છે.

Theory

counter પર Trays

shop counter જેના પર coins, notes અને receipts loose પડ્યા હોય એ chaos છે; દરેક kind ને tray માં મૂકો અને અચાનક તમે આખા tray ને once lift, move અથવા lock away કરી શકો છો.

container control એ controls માટે tray છે: children તેની અંદર live કરે છે, તેની સાથે move થાય છે, તેની સાથે disable થાય છે. અને tray જેવું, તે also quieter question ને answer કરે છે: which items belong together, જે exactly એ છે જે those radio buttons ને hear કરવાની જરૂર હતી.

Theory

3 containers, ઔપચારિક રીતે

  • Panel: plain rectangle જે children ને hold કરે છે; કોઈ caption નહીં. તેનું AutoScroll property scrollbars ને add કરે છે જ્યારે children overflow થાય: long forms માટે good.
  • GroupBox: border WITH caption (તેનું Text property). group ને label કરવા standard રીત: "Payment mode".
  • TabControl: TabPages નો stack, file dividers જેવો: ShopKeeper ને 3 separate windows વગર Billing, Day Report અને Settings tabs મળે છે.

Collective behaviour એ point છે: container નું Enabled ને False પર set કરો અને અંદર દરેક child એક સાથે grey થઈ જાય છે.

Theory

Containers radio groups ને define કરે છે

અહીં rule છે જે hook tripped over થયો:

RadioButtons તેમના container ની અંદર mutually exclusive છે. એક container ને share કરતા બધા radios ONE group બનાવે છે; તેમના બધા માંથી one selection.

fix એ 2 trays છે: GroupBox captioned Payment mode જે rdoCash, rdoCard, rdoUPI ને hold કરે છે, અને બીજો GroupBox captioned Delivery જે rdoTakeAway, rdoHome ને hold કરે છે. હવે Card અને Home delivery coexist કરે છે, કારણ કે દરેક group તેની own election ને privately settle કરે છે.

Quiz

form પર 5 RadioButtons છે જે સીધા તેના પર placed છે: 3 payment માટે, 2 delivery માટે. observed behaviour શું છે?

  1. Payment અને delivery independently work કરે છે: VB.NET તેમને name prefix દ્વારા groups કરે છે
  2. બધા 5 એક exclusive group બનાવે છે: કોઈ પણ button ને select કરવાથી બાકીના 4 deselect થાય છે
  3. Compile error: RadioButtons ને GroupBox વગર placed નથી કરી શકાતા
  4. ફક્ત first 3 placed buttons work કરે છે; બાકીના ને ignore કરવામાં આવે છે
Show the answer

બધા 5 એક exclusive group બનાવે છે: કોઈ પણ button ને select કરવાથી બાકીના 4 deselect થાય છે

form itself એ એક big container છે, એટલે દરેક directly-placed radio એક merged group માં join થાય છે: Home delivery ને choose કરવાથી Card deselect થાય છે, precisely hook નું bug. Option A naming convention ને invent કરે છે જે exist નથી કરતું; grouping containment ને follow કરે છે, ક્યારેય names નહીં. Option C false છે: form એ perfectly legal container છે, just અહીં wrong one. Option D placement-order rules ને invent કરે છે. exam માટે એક sentence માં fix: દરેક logical group of RadioButtons ને તેના own container માં મૂકો, usually GroupBox.

Think first

tray ને pick કરો

ત્રણ needs: (1) payment radios ની આસપાસ labelled box, (2) 40-item stock list માટે scrollable area, (3) Billing અને Settings એક window માં separate screens તરીકે. Panel, GroupBox અને TabControl ને assign કરો tap કરતા પહેલા.

Show the answer

(1) GroupBox: તે 3 માંથી only one છે જેની પાસે built-in caption છે, અને labelled radio groups એ તેનું signature job છે. (2) Panel AutoScroll = True સાથે: plain, uncaptioned, scroll કરે છે જ્યારે children overflow થાય. (3) TabControl: એક window, multiple TabPages, separate forms નું કોઈ juggling નહીં. internalise કરવાનો pattern: caption wanted = GroupBox, scrolling wanted = Panel, sections wanted = TabControl.

Watch out

Container slips જે time cost કરે છે

control ને GroupBox ની અંદર ને બદલે NEAR drop કરવું: તે અંદર look કરે છે પણ form ને belong કરે છે; તેના radios પછી form ના group માં join થાય છે અને bug returns થાય છે. container highlight થાય ત્યાં સુધી Drag કરો, અને container ને move કરીને verify કરો: true children તેની સાથે move થાય છે.

container ને delete કરવાથી તેના children delete થાય છે: controls ને પહેલા બહાર lift કરો.

Z-order confusion: Panel જે control પછી draw થાય છે તે તેની ON TOP sit કરી શકે છે; right-click, Send to Back.

Theory

Containers એ structure છે, decoration નહીં

Beginners GroupBoxes ને cosmetic borders તરીકે see કરે છે. Professionals containment ને LOGIC તરીકે use કરે છે: radio grouping, collective enable/disable (items exist થાય ત્યાં સુધી આખા payment section ને lock કરો: grpPayment.Enabled = False, one line), અને layout જે resizing ને survive કરે છે. BCA402-02 નો UI/UX subject આ principle ને proximity નામ આપશે: related things visibly together belong કરે છે. next lesson till ને તેનો most important tray મળે છે: DataGrid જે bill ને show કરે છે, DataSet દ્વારા fed.

Summary

Key takeaways

  • Containers child controls ને hold કરે છે: container ને move, hide અથવા disable કરો અને children follow થાય છે.
  • Panel = plain + AutoScroll; GroupBox = captioned border; TabControl = sections તરીકે TabPages.
  • RadioButtons PER CONTAINER exclusive છે: એક container, એક group, એક selection.
  • બે independent radio groups ને 2 containers (GroupBoxes) જોઈએ છે, અથવા તેઓ એક fighting group માં merge થઈ જાય છે.
  • controls ને container ની અંદર drop કરો (highlight ને watch કરો), તેની પર merely on top નહીં.
  • container પર collective Enabled/Visible એ one-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