software engineering iv section 12 programming with windows form controls n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Software Engineering IV Section 12. Programming with Windows Form Controls PowerPoint Presentation
Download Presentation
Software Engineering IV Section 12. Programming with Windows Form Controls

Loading in 2 Seconds...

play fullscreen
1 / 28

Software Engineering IV Section 12. Programming with Windows Form Controls - PowerPoint PPT Presentation


  • 308 Views
  • Uploaded on

Software Engineering IV Section 12. Programming with Windows Form Controls . Xavier López Gavarró xavier.lopezg@estudiants.urv.es. Copyright. © University Rovira i Virgili

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Software Engineering IV Section 12. Programming with Windows Form Controls' - emily


An Image/Link below is provided (as is) to download presentation

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.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
software engineering iv section 12 programming with windows form controls

Software Engineering IVSection 12. Programming with Windows Form Controls

Xavier López Gavarró

xavier.lopezg@estudiants.urv.es

slide2

Copyright

  • © University Rovira i Virgili
  • Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; provided its original author is mentioned and the link to http://libre.act-europe.fr/ is kept at the bottom of every non-title slide. A copy of the license is available at:
  • http://www.fsf.org/licenses/fdl.html
index
Index
  • Windows Applications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
1 windows aplications in net
1. Windows Aplications in .NET
  • Before .NET developers had several choices in building a Windows Applications:
    • Win32 API
    • MFC is a productivity class library using C++ that encapsulates the Win32 API
    • Visual Basic
  • However, neither of these solutions utilizes the .NET or the CLR.
  • The .NET contains a new productivity layer that encapsules the win32 API, and much like MFC and Visual Basic, it allows for easier and more eficient development of Windows applications. This envirotment is called Windows Forms.
1 windows aplications in net1
1. Windows Aplications in .NET
  • Windows Forms are the new Microsoft .NET GUI libraries.
  • The Forms library contains most of the graphic controls that GUI developers are used to work with.
  • Almost every windows forms applications extends the funcionality of: System.Windows.Forms
index1
Index
  • Windows Applications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
2 windows forms without visual studio net
2.Windows Forms Without Visual Studio .NET
  • To better understand how Windows Forms operates and how it interacts with the .NET, we will build a complete windows applications without the use of VS .NET:
2 windows forms without visual studio net1
2.Windows Forms Without Visual Studio .NET
  • The simplest Windows Form application would be the following:

using System;

using System.Windows.Forms;

namespace WindowsFormsApp

{

class MyForm : Form

{

static void Main(string[] args)

{

MyForm aForm = new MyForm();

Application.Run(aForm);

}

}

}

2 windows forms without visual studio net2
2.Windows Forms Without Visual Studio .NET
  • Controls:
    • Basically every control on a form is a data member of the custom Form class

class MyForm : System.Windows.Forms.Form

{

//Data member to hold Button control

private Button BigButton;

2 windows forms without visual studio net3
2.Windows Forms Without Visual Studio .NET
  • Before this data member will do anything or display a button on the form, it must be initialized and the button’s various properties must be configured. This should be done in the constructor for the MyForm object.

public MyForm()

{

//Set the properties for the Button

this.BigButton = new Button();

this.BigButton.Location = new System.Drawing.Point(50, 50);

this.BigButton.Name = "BigButton";

this.BigButton.Size = new System.Drawing.Size(100, 100);

this.BigButton.Text = "Click Me!";

//Set properties for the Form itself

this.ClientSize = new System.Drawing.Size(400, 400);

this.Controls.Add(this.BigButton);

this.Text = "My Windows Form!!!";

}

2 windows forms without visual studio net4
2.Windows Forms Without Visual Studio .NET
  • Events:
    • Most Windows Forms event handlers have this method signature:

private void ClickHandler(object sender, System.EventArgs e)

{

MessageBox.Show("Clicked!","My Windows Form",MessageBoxButtons.OK);

}

  • The first parameter contains the object that raised the event.
  • The next parameter contains data about the event in a System.EventArgs parameter or derived class.
2 windows forms without visual studio net5
2.Windows Forms Without Visual Studio .NET
  • Finally, add the following code to the MyForm constructor to attach our event handler to the event in the MyForm class:

this.BigButton.Click += new System.EventHandler(this.ClickHandler);

  • The System.EventHandler delegate is used to reference the ClickHandler( ) method and it is associated with the button’s Click event by simply adding it to the Click event handler chain.
index2
Index
  • Windows Applications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
3 windows forms using visual studio net
3.Windows Forms Using Visual Studio .NET
  • Using Visual Studio .NET makes Windows Forms applications much simpler.
  • Steps:
    • Start Microsoft Visual Studio .NET.
    • On the File menu, point to New, and then click Project.
    • In the New Project dialog box, click Visual C# Projects under Project Types, and then click Windows Application under Templates.
    • Drag the controls from the toolbox onto the form.
    • Change the properties of the controls.
index3
Index
  • Windows Applications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
4 windows controls
4. Windows Controls
  • The .NET ships with many controls ready to incorporate into windows Forms applications:
    • Label, LinkLabel, textbox, button, checkbox, CheckedListBox, RadioButton, ColorDialog, ComboBox, DataGrid, FontDialog, listbox, ListView, monthCalendar, treeview, Panel, PictureBox, trackBar, progressBar...
4 windows controls1
4. Windows Controls
  • Label:It is used to show static text.
  • Textbox:It allows the text introduction for the user.
4 windows controls2
4. Windows Controls
  • Button:control in which one can do click to carry out some action.
  • Checkbox:It is used mainly to show the binary state of an object. When clicking in the CheckBox it is commuted among the activated states and disabled.
4 windows controls3
4. Windows Controls
  • Listbox:It contains a list of elements that you can be selected. When it is filled the visible part of the Listbox, a displacement bar that allows to consent to elements that are outside of the view appears.
4 windows controls4
4. Windows Controls
  • MonthCalendar:Control that shows a calendar.
4 windows controls5
4. Windows Controls
  • Tree views:It shows elements in a hierarchical way. It possesses a node root in the superior part of the tree and it can have it varies ramifications and nodes.
  • TrackBar:This control is usually useful to establish the frequency or speed with which takes place a concrete operation.
4 windows controls6
4. Windows Controls
  • ProgressBar:It is used to show the state of an operation in course. It has a graphic indicator, configured by the program to show the percentage of realization of a task.
index4
Index
  • Windows Aplications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
5 visual inheritance
5. Visual Inheritance
  • The .NET environment takes of inheritance and allows a developer to use it to develop Windows Forms applications
  • A Form object can inherit from another Form object, thus gaining acces to all the contained controls, as well as non-display-related methods and properties.
  • This is a very powerful feature in .NET that when used properly dramatically reduces the amount of code required for creating similar screens and windows.
5 visual inheritance1
5. Visual Inheritance
  • Implementing visual inheritance simply requires a developer to instead derive the Form object from a custom Form class instead of System.Windows.Forms.
index5
Index
  • Windows Aplications in .NET
  • Windows Forms Without Visual Studio .NET
  • Windows Forms Using Visual Studio .NET
  • Windows Controls
  • Visual Inheritance
  • Net Visual Components vs Swing
6 net visual components vs swing
6. Net Visual Components vs Swing
  • Swing is cross-platform
  • Swing is still slow on Win32 and Linux
  • Winforms is quicker than Swing in Windows.
  • Swing applications looks simple and unreliable (toy alike), and Winforms applications looks more mature.
references
References
  • MSDN Library of Visual Studio .NET
  • Professional C#. Wrox, 2nd Edition, 2003.
  • C# Al descubierto. Prentice Hall, First Edition, 2002. Joseph Mayo.