Icons and Buttons
C
Coonncceepptts s : : NNoorrmmaall Fi
Files les anand d fofoldelders rs : : NoNormrmal al bebetwtweeeen n quoquotestes, , e.e.g. g. "f"frmrmLoLogingin.c.cs"s".. Cla
Classsses and Coes and Contrntrols ols : Gree: Green, e.gn, e.g.. ColorColor,, PictureBoxPictureBox P
Prrooppeerrttiiees s : : BBoolldd, , ee..gg.. NameName P
Proropepertrty y vavalulues es : : As As it it aappppeearars s in in cocodede, , e.e.g.g. "John""John",, 1010,, CenterScreenCenterScreen.. M
Meetthhoodds s : : BBoolld d wwiitth h bbrraacckkeettss, , ee..gg.. Show()Show() E
Evveenntts s : : BBoolld d wwiitth h tthhe e wwoorrd d ""eevveenntt"", , ee..gg.. ClickClick eventevent E
Evveennt t hhaandndlelerrs s : : AAs s ffoor r mmeetthhoodsds, , ee..g.g.Close()Close().. R
Exercises
Exercises
1.
1. CrCreaeate a te a WiWindndowows Fors Forms apms applplicicatatioion n to alto allolow a w a ususer to ener to enteter hisr his/h/her tier titltle, nae, name anme andd sur
surnamname. e. Add labAdd labelsels, text box, text boxes, butes, buttontons and a s and a cocombo box as in the exambo box as in the examplmple. e. WheWhenn th
the e ususer er cclilicckks s on on ththee GreetingGreeting bubuttttonon, , a a memessssagage e shshouould ld be be didispsplalayeyed d ththat at wiwillll concatenate the user entries in the three fields and display a greeting.
concatenate the user entries in the three fields and display a greeting. Hint: Use the
Hint: Use the ItemsItems collection in the Properties window of the combo box to enter thecollection in the Properties window of the combo box to enter the po
possssiblible e tititltleses. . DuDuriring ng rurun-n-titimeme, , yoyou u cacan n obobtatain in the the ususerer's 's seseleclectiotion n frfrom om ththe e TeTextxt property as for the text boxes.
property as for the text boxes.
2.
2. CreCreate ate a Wia Windondows Fws Formorms aps applicplicatiation ton that hat wilwill all allow low the the useuser to r to selselect ect a spa sportorts cos code frde fromom a set
a set of radio buttof radio buttonsons. . WheWhen the n the useuser r cliclicks the buttocks the button, an n, an appapproprropriatiate messae message andge and pic
picturture must be e must be disdisplaplayedyed. . YoYou u may be creamay be creativtive with the e with the mesmessasagesges. . See if you can findSee if you can find o
ouut t wwhhaat t tthhe e ddiiffffeerreenncce e iis s bbeettwweeeen n tthhe e ddeeffaauullt t eevveennt t ffoor r a a rraaddiio o bbuuttttoonn,, CheckedChanged
CheckedChanged, and the, and the ClickClick event.event. Hi
Hintnt: : ThTherere e arare e sosome me exexamample ple picpictutureres s avavaiailalable ble on on the the CD CD ththat at acaccocompmpananies ies ththisis tu
tutotoriarial. l. CoCopy py ththesese e intinto o ththe e "\"\binbin\D\Debebug" foldug" folder er of of yoyour ur apappliplicacatition on anand d ususe e ththee ImageLocation
ImageLocation property to load them into the picture box, for example:property to load them into the picture box, for example: picSport.I
3.
3. CoConsnsideider thr the foe follollowiwing sng scecenarnarioio: : YoYou hau have bve beeeen asn askeked to dd to devevelelop a pop a prorogragram thm that cat canan be used by
be used by a a lelectctururer er to obtato obtain in ststatatisistitics on cs on ththe e ststudeudentnts s in his in his clclasass. s. DeDevevelolop p anan application with a form as in the example and characteristics as below:
application with a form as in the example and characteristics as below:
So
Solutlutioion n sasaveved d as as : : ChCh01E01Ex0x03.3.slslnn Form
Form - Sa
- Savveed d aas s : : ffrrmmNNaammeeSSuurrnnaammee..ccss -
- CCaappttiioon n : : NNaamme e aannd d SSuurrnnaammee -
- HeHeigight ht & W& Wididth th : 2: 235 35 & 4& 46767 -
- StaStartirting posng positioition in the middn in the middle of the scle of the screereenn -
- CanCannot bnot be rese resized dized durinuring run-g run-timtimee -
- Cannot Cannot be minimbe minimised oised or maximr maximised duised during runring run-time-time Controls:
Controls: -
- LabLabels aels and texnd text boxes ft boxes for namor name and sure and surnamnamee -
- LabLabel and dael and date/te/time btime box for dox for date of biate of birthrth -
- LabLabel anel and comd combo box bo box for dfor degreegree.e. -
- AvailAvailable itemable items: B.Scs: B.Sc., B.Com.., B.Com., B.A., B.T, B.A., B.Th., B.Ed.h., B.Ed., Other., Other. -
- IteItems in the box musms in the box must alwayt always be sortes be sorted alphad alphabetibeticacallylly.. -
- GroGroup with raup with radio butdio buttontons as in the exas as in the examplemple. . A studeA student can stnt can study for onudy for only one degly one degreeree at a time.
at a time. -
- GroGroup with cheup with check boxeck boxes as in the exams as in the example. ple. A studeA student may havnt may have subjee subjects frcts from moreom more than one year and must therefore be able to select more than one box.
than one year and must therefore be able to select more than one box. -
- Button to Button to clear all cclear all contentontents with shos with shortcut artcut as indicas indicatedted -
- Button to eButton to exit applixit applicatiocation with shon with shortcut artcut as indicas indicatedted -
- All coAll contrntrols mols must be prust be properoperly namly nameded -
- All conAll controtrols must be propls must be properlerly aligny aligned and spaed and spacedced -
- The useThe user shoulr should be able to move focd be able to move focus from one cous from one controntrol to the other in a logical to the other in a logicall order with
order with Tab/Shift-TabTab/Shift-Tab.. Code
Code -
- FFoorr ClearClear buttonbutton -
- FFoorr ExitExit buttonbutton Comment
Comment -
- StuStudendent numt numberber, na, name anme and datd datee -
- RunnRunning coing commemment to explant to explain whain what the codt the code is doinge is doing 4.
4. DDeevevelolop a sp a simimpple le foform arm as is in tn the he eexaxampmplele. . WWhehen tn the he ususerer cl
clicicks ks on on ththe e butbuttoton, n, the the foformrm's 's babackckgroground und cocoloulour r mumustst ch
chanange ge to to liglight ht blblue ue anand d the buttthe button on mumust st chchanange ge toto GreyGrey.. When the user clicks the
When the user clicks the GreyGrey button, the form's backgroundbutton, the form's background colour must change back to grey and the button to
colour must change back to grey and the button to Light blueLight blue.. Hint: To obtain a colour, type the class
Hint: To obtain a colour, type the class ColorColor followed by afollowed by a period and use