Working with Tool Box Controls: common controls - Label, Text Box, Button, Check Box, Radio Button, Date Time Picker, List Box, Combo box, Picture Box, Rich Text Box, Tree View, Tool Tip, Progress bar, Masked Text box, Notify Icon, Link Label, Checked List box

દરેક Toolbox control એક જ 3-part deal છે (properties, events, methods): pattern એક વાર શીખો, પછી family table વાંચો: typing માટે TextBox, one-of માટે RadioButton, any-of માટે CheckBox, pick-from-list માટે ComboBox.

12 min read · 10 cards · 2 checks

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


Theory

Till ને control by control design કરો

તમારી જાતને મહેતા સ્ટોર્સના counter પર મૂકો અને billing screen ને શું જોઈએ છે તેની યાદી બનાવો:

એક title (ફક્ત display થાય), item name type કરવા માટે એક box, ફક્ત digits માં typed થતી quantity, Cash/Card/UPI માંથી પસંદ કરેલો ફક્ત એક payment mode, ઉપરથી કદાચ ઉમેરાતી carry-bag, bill ની date, એક Add button અને day report બને ત્યાં સુધી એક progress bar.

એ યાદીની દરેક જરૂરિયાત બરાબર એક Toolbox control સાથે map થાય છે. આ પાઠ એ map છે, અને એક જ pattern આ 17 ને શીખવા લાયક બનાવી દે છે.

Formula

3-part pattern (એક વાર શીખો, 17 વાર વાપરો)

દરેક control એક જ 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 નો જવાબ આ જ આકારમાં આપો અને marks પાછળ આવશે.

At a glance

રોજિંદા આઠ

ControlTill પરનું કામKey propertyKey event
Labelફક્ત display થતું text (shop name)Text(ભાગ્યે જ handle થાય)
TextBoxItem name type કરવુંTextTextChanged
ButtonItem ઉમેરવું, bill print કરવુંTextClick
CheckBoxAny-of extras (carry bag)CheckedCheckedChanged
RadioButton3 માંથી ફક્ત એક payment modeCheckedCheckedChanged
ComboBoxUnit પસંદ કરવો (kg/pkt/pc)SelectedItem, ItemsSelectedIndexChanged
ListBoxદેખાતી list માંથી પસંદ કરવુંItems, SelectedIndexSelectedIndexChanged
DateTimePickerBill ની dateValueValueChanged

At a glance

Specialists

Controlખાસિયતઆ રીતે યાદ રાખો
MaskedTextBoxTyping ને pattern માં force કરે છે10-digit phone માટે Mask = "0000000000"
ProgressBarલાંબા task નું feedbackMinimum, Maximum, Value
PictureBoxImage બતાવે છેImage, SizeMode
RichTextBoxFormatted text (bold, colour)Typography વાળું TextBox
TreeViewHierarchies (category > item)Nodes
ToolTipબીજા control પર hover hintSetToolTip(btnAdd, "Adds to bill")
NotifyIconSystem tray માં રહે છેMinimised રહીને પણ till ચાલુ રહે છે
LinkLabelClickable link textLinkClicked
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 એ બરાબર એક જ payment mode પસંદ કરવો પડે છે, અને મહેતા અંકલ ઇચ્છે છે કે ત્રણેય options એક નજરમાં દેખાય. કયું control fit થાય છે?

  1. Cash, Card, UPI નામના ત્રણ CheckBoxes
  2. Cash, Card, UPI નામના ત્રણ RadioButtons
  3. એક TextBox જેમાં cashier mode type કરે
  4. ત્રણ Buttons, દરેક mode માટે એક
Show the answer

Cash, Card, UPI નામના ત્રણ RadioButtons

RadioButtons બરાબર exactly-one-of-few માટે જ BUILT થયેલા છે: એક select કરો એટલે તેના siblings આપોઆપ deselect થાય છે, અને બધા options દેખાતા રહે છે. CheckBoxes independent હોય છે, એટલે Cash અને Card બંને ticked થઈ શકે: checkboxes એટલે any-of, radios એટલે one-of, અને આ પ્રશ્ન એ જ ભેદ drill કરવા માટે છે. TextBox typos ને આમંત્રણ આપે છે ("cassh") અને validation નું દુઃખ ઊભું કરે છે. Buttons choice યાદ રાખવાને બદલે actions fire કરે છે; click પછી screen પર કંઈ બતાવતું નથી કે કયો mode selected છે. ComboBox પણ one-of enforce કરત, પરંતુ એ options ને એક click પાછળ છુપાવે છે, એટલે visible-at-a-glance requirement fail થાય છે.

Think first

Quantity box સુધી alphabet પહોંચતું અટકાવો

Quantity ફક્ત digits હોવી જોઈએ, અને phone numbers બરાબર 10 digits. સાદું TextBox "abc" ને ખુશીથી સ્વીકારી લે છે. Specialists table જુઓ: કયું control આ TYPING stage પર જ ઠીક કરે છે, અને કેવી રીતે?

Show the answer

MaskedTextBox, તેની Mask property દ્વારા: Mask = "0000000000" બરાબર 10 digits સ્વીકારે છે અને type થતી વખતે જ letters ને physically નકારે છે; કોઈ validation code નહીં, કોઈ error message નહીં, કારણ કે ખોટું input અંદર આવી જ શકતું નથી. એની પાછળનો design પાઠ: શ્રેષ્ઠ validation એ control છે જે invalid input ને અશક્ય બનાવે, એટલે કે Unit 2 ના Enum idea નું UI cousin. જે rules mask વ્યક્ત ન કરી શકે (price positive હોવી જોઈએ) એ માટે તમે code માં validate કરો જ છો, અને 3 પાઠ પછી આવતું ErrorProvider component એની polite રીત બતાવશે.

Watch out

Control પસંદ કરવાની ત્રણ ભૂલો

RadioButton ની જગ્યાએ CheckBox: any-of vs one-of; Cash અને Card બંનેથી ચૂકવાયેલું bill એ designer માં જન્મેલો data bug છે.

TextBox.Text હંમેશા String હોય છે: arithmetic પહેલાં CInt(txtQty.Text) કરો, બરાબર Unit 2 ના InputBox ની જેમ; "2" & 3 એ 5 નથી.

Space પ્રમાણે ListBox vs ComboBox: idea એક જ છે (Items માંથી પસંદ કરવું); ListBox list કાયમ બતાવે છે, ComboBox એને વાળીને છુપાવે છે. ફક્ત દેખાવ પરથી પસંદ કરવું, WHY કહ્યા વગર, reasoning નો mark ગુમાવે છે.

Theory

કોઈપણ નવું control 30 seconds માં વાંચો

આ pattern આ syllabus થી આગળ પણ generalise થાય છે: VB.NET માં કે Android માં કોઈ પણ અજાણ્યું control મળે (BCA305-02 ના widgets પણ એ જ deal હતા), ત્યારે 3 પ્રશ્ન પૂછો: તેની key properties કઈ છે? એ કયા events raise કરે છે? કયા methods અગત્યના છે? Properties window પહેલા 2 ના જવાબ સીધા આપે છે (તેની lightning-bolt tab events list કરે છે). આગળનો પાઠ: આ controls ને group કરતા containers, અને એ topic ની અંદર છુપાયેલી radio-button surprise.

Summary

Key takeaways

  • દરેક control = properties (settings) + events (announcements) + methods (orders).
  • Core mapping: Label display કરે, TextBox type કરાવે, Button click લે, DateTimePicker dates આપે.
  • Choices: CheckBox = any-of (independent); RadioButton = exactly-one-of; ComboBox/ListBox = Items માંથી પસંદગી.
  • Specialists: MaskedTextBox typing pattern force કરે, ProgressBar Minimum અને Maximum વચ્ચે Value બતાવે, ToolTip hover hints જોડે, NotifyIcon tray માં બેસે.
  • TextBox.Text એક String છે: arithmetic પહેલાં convert કરો.
  • પછીથી ઠપકો આપતા code કરતાં invalid input ને અશક્ય બનાવતાં controls પસંદ કરો.
  • Memory hook: radios એક પસંદ કરે, checks ઘણા પસંદ કરે, combos list માંથી પસંદ કરે.

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

Working with Tool Box Controls: common controls - Label, Text Box, Button, Check Box, Radio Button, Date Time Picker, List Box, Combo box, Picture Box, Rich Text Box, Tree View, Tool Tip, Progress bar, Masked Text box, Notify Icon, Link Label, Checked List box · .NET Programming · Gri-Learn