Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
A AN N N NA AJ JA AH H N NA AT TI IO ON NA AL L U UN NI IV VE ER RS SI IT TY Y V VI IS SU UA AL L B BA AS SI IC C. .N NE ET T F FO OR RM MS S M MA AN NA AG GE EM ME EN NT T I IN NF FO OR RM MA AT TI IO ON N S SY YS ST TE EM MS S P PR RE EP PA AR RE ED D B BY Y : : M MO OH HA AM MM ME ED D A AB BD DE EL L K KH HA AL LE EQ Q D DW firstname.lastname@example.org :facebook.com/dwikatmo : email@example.com WI IK KA AT T 1 14 4/ /0 01 1/ /2 20 01 19 9 V VI IS SU UA AL L B BA AS SI IC C. .N NE ET T F FO OR RM MS S/ /A AP PP PL LI IC CA AT TI IO ON NS S 1 1. .P PR RO OP PE ER RT TI IE ES S 2 2. .E EV VE EN NT TS S 3 3. .M ME ET TH HO OD DS S Form is a class. Form is the container/Area that holds all controls and makes the interface of the application. AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:firstname.lastname@example.org TOPIC:VISUAL BASIC II/FORMS DATE:14/01/2019PAGE:1 OF 5
F FO OR RM M O OB BJ JE EC CT T P PR RO OP PE ER RT TI IE ES S O OF F A A F FO OR RM M Name: a name is given to a form in design time to be used later in code. Once a name property is assigned, it cannot be changed later in code. Other properties can be changed at design time or at run time (in code) Property values Controlbox True/False Show/Hide control box MaximizeBox True/False Show/Hide Max/Restore box MinimizeBox True/False Show/Hide Minimize box Opacity 0-100% 0 like glass,1 like cover,0.5 half/half Text Any text Description Icon Icon File WindowState Normal, Minimize, Maximize ShowInTaskBar True/False What is Windows task bar? KeyPreview True/False Register keypress by form RightToLeft Yes/No Form direction Width Any number No. of pixels Height Any number No. of pixels Backcolor Color.red Background color of a form Forecolor Color.blue eg. Forecolor for labels on a form Tag Any value Used as temp value for any type Important note: Use ME when effect will take place on current form or form name if effect will take place on different form AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:email@example.com TOPIC:VISUAL BASIC II/FORMS DATE:14/01/2019PAGE:2 OF 5
E EV VE EN NT TS S O OF F A A F FO OR RM M Event: it is the name of action that needs a reaction (code to be run upon action) Event Load Click MouseClick MouseDown MouseUp KeyPress KeyDown KeyUp FormClosing Upon closing the form FormClosed After the form is closed Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Write code here'For example to initialize variable values End Sub You can ask user if he want to save changes when (before) the form closed Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosing 'If Data changed then ask user whether to save it or not End Sub M ME ET TH HO OD DS S O OF F A A F FO OR RM M If we want to close any form by code written on the form itself, we write Method COMMENTS close Close the form (remove it from memory) - me.close , form1.colse show Show the form - form1.show() showdialog Show the form as dialog –form1.showDialog() Hide Me.hide or form1.hide (remains in memory) Centertoparent Display it centered relative to parent CenterToScreen Display it centered relative to screen The .close() method, will close any form and remove it from memory, we write the form name to be closed as Close form2 (code is written on form2) Close form2 (code is written on form1) Open form2 code COMMENTS When form loaded into memory Any click = MouseDown + MouseUp Mouse is pushed down Mouse is released up =KeyDown + KeyUp Key is pushed down Key is released up formName.close() me.close() form2.close() AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:firstname.lastname@example.org TOPIC:VISUAL BASIC II/FORMS DATE:14/01/2019PAGE:3 OF 5
What is Dialog mean– it means a form is shown and your action is required before you can go to previous form or any other form) Form2.ShowDialog() (you can’t go back to from1 unless you close form2) Form2.Show()’(you can go back to from1 then again to form2 and so on) Close form2 when clicking on it Me.Close() 'This will close any form that is written on it U US SE E F FO OR RM M E EV VE EN NT TS S, , P PR RO OP PE ER RT TI IE ES S A AN ND D M ME ET TH HO OD DS S U US SI IN NG G E EV VE EN NT T K KE EY YP PR RE ES SS S 1 1. .H HO OW On the event Keypress of the form, you can read the key pressed on the keyboard, (provided that the form keypreview is set to true) T1.Text = e.KeyChar (one character) 2 2. .H HO OW W T TO O C CH HA AN NG GE E T TH HE E K KE EY Y P PR RE ES SS SE ED D W If Asc(e.KeyChar) = Asc(vbCrLf) Then SendKeys.Send(vbTab) The same is applied if you want to prevent keyboard from writing letters in a textbox, only allow numeric textbox to accept numbers from 0 to 9 an minus -, and dot . ASCII code for 0 is 48, for 9 is 57, for minus sign is 45, for dot . is 46 We write the following code on keypress event Select Case Asc(e.KeyChar) Case 48 To 57, 45, 46 Case Else e.KeyChar = "" End Select 2 2 W To see the form properties press F4, change it, run to see changes you can also change the properties by code (except the name) assume we have form1 or you can change it by code like this Form1.Text = "ةشاشلاةيسيئرلا" W This means we can create object that is identical to the original class, for example this code Dim f As New Form1 f.Show() Whenever executed, create a copy of the form f1, then display it. Please note that any object created is hidden (Not visible) by default. W T TO O R RE EA AD D A A K KE EY Y T TH HA AT T I IS S P PR RE ES SS SE ED D O ON N A A F FO OR RM M WI IT TH H A AN NO OT TH HE ER R O ON NE E ( (C CH HA AN NG GE E E EN NT TE ER R T TO O T TA AB B) ) WA AY YS S T TO O C CH HA AN NG GE E P PR RO OP PE ER RT TI IE ES S O OF F A AN N O OB BJ JE EC CT T( (f fo or rm m o ob bj je ec ct t h he er re e) ) WH HY Y F FO OR RM M I IS S C CO ON NS SI ID DE ER RE ED D A AS S C CL LA AS SS S AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:email@example.com TOPIC:VISUAL BASIC II/FORMS DATE:14/01/2019PAGE:4 OF 5
H HO OW Me.Text = "Main Screen" Me.ShowInTaskbar = True Me.BackColor = Color.Black Me.Cursor = Cursors.Hand Me.ForeColor = Color.Chocolate Me.MaximizeBox = False Me.MinimizeBox = False Me.ControlBox = False Me.Opacity = 0.88 W T TO O H HA AN ND DL LE E F FO OR RM M P PR RO OP PE ER RT TI IE ES S U US SI IN NG G C CO OD DE E Change main title 1 Not transparent, 0 fully transparent like glass Me.Width = 500 Me.Height = 500 Me.RightToLeft = True If you want to change property of form (fSales) but the code is written on another form, replace me by fsales as fSales.Text = "Main Screen" fSales.BackColor = Color.Black Task1 Create 2 forms, on click event of form1, write Form2.show On click event of form 2, write Me.colese Self evaluation questions Write the vb.net code to accomplish the following of form1 Change the main title to be Payroll system. Make the form visible on taskbar Hide the minimize box Set the form to be right to left Display form1 as dialog form Which event you use to read any key pressed on the form, which property should be used to make it works, what is its value Event :Keypress, Property: KeyPreview, Value true AUTHOR:MOHAMMED ABDEL KHALEQ DWIKATEMAIL:firstname.lastname@example.org TOPIC:VISUAL BASIC II/FORMS DATE:14/01/2019PAGE:5 OF 5