Docsity

25_09. EVENT DRIVEN PROGRAMMING.pdf, Study Guides, Projects, Research of Programming Languages

Partial preview of the text

Download 25_09. EVENT DRIVEN PROGRAMMING.pdf and more Study Guides, Projects, Research Programming Languages in PDF only on Docsity!

Event Driven Programming

  • GUI & Visual programming
  • Form and controls
    • Label
    • Textbox
    • Button
  • Event-driven programming
  • Form and controls (cnt.)
    • CheckedBox
    • Radio Button
    • ListBox
    • ComboBox
    • Menu
    • ContextMenu Topics

Creating GUI application

Windows Application template Select File New Project Name

Creating GUI application

Properties Window Form Toolbox Design View

  • Main program windows, includes controls
  • Form class has a lot of properties and methods
    • Properties can be changed in Design View
    • Or in Code View
  • Form class has many events that can be programmed as programmer wants - Close form - Mouse moves - Mouse clicks (left or right) - etc Forms

Form Properties Properties Property value Categorized Alphabetical Events

  • Several Form’s methods:
    • Activate: make Form object to get focus
    • Close: close Form object
    • Hide: hide Form object
    • Show: show Form object (user can see it now) Form methods
  • Many events can happen on a Form object: key board pressed, mouse clicked, mouse moved, etc.
  • When an event happens, system will call a specific method for that event to response to it
  • Programmer need to write that specific method
  • Event-driven programming:
    • Event is the key. Logic of program is represented by events
    • Programmer select event that is useful for program to implement (not all) Form Events
  • Controls are:
    • Button, Label, TextBox, ComboBox, MainMenu, ListBox, CheckBox, RadioButton, and MonthCalendar, etc.
  • Each control has different properties / methods / events. Some are common among controls (Text, Size, etc.)
  • Controls are inherited from System.Windows.Forms.Control Controls
  • They are:
    • System.Windows.Forms.Label
    • System.Windows.Forms.TextBox
    • System.Windows.Forms.Button
    • V.v.
  • Form’s controls are object of these classes Sub classes of Control object object object object object object

Controls

examples

  • From Toolbox, select and drag necessary control to Form
  • Control position can be moved, size can be changed
  • Controls alignment
    • Aligned
    • Same size
    • Horizontal align, vertical align
    • Etc. Add controls on Form (visual programming)

Common method Controls

Controls example