Difference between revisions of "OOP Class9"

esse quam videri
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Object Oriented Programming]]
 
[[Category:Object Oriented Programming]]
  
==Dog and Dog Binding==
 
  
DataBound controls can bind to anyting that implements [http://msdn2.microsoft.com/en-us/library/system.collections.ienumerable.aspx IEnumerable]
 
It's easier in 2.0 + to just inherit from [http://msdn2.microsoft.com/en-us/library/system.collections.icollection.aspx ICollection]
 
 
http://iam.colum.edu/oop/classsource/class9/DogBinding.aspx [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/DogBinding.aspx source] [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class9/DogBinding.aspx.cs codebehind]
 
 
TODO in class Bark a Dog...
 
 
Special Files
 
*web.config
 
 
Special Folders
 
*App_Code
 
*Bin
 
*App_Data
 
  
 
==Motorvehicle Diagram==
 
==Motorvehicle Diagram==

Revision as of 14:33, 5 November 2008



Motorvehicle Diagram

Oop Motorvehicle Diagram

http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class7/MotorvehicleRace

Windows forms

Events

events from a windows form or web page are handled by event handlers. Events are raised when a user interacts with interface elements and handled by the event handlers.


http://www.csharphelp.com/archives/archive253.html

Examaple of event handlers and classes

http://iam.colum.edu/oop/MotorvehicleRace.zip

<csharp> private void button1_Click(object sender, EventArgs e)

       {
           Console.WriteLine("button1 Clicked");
           MessageBox.Show("button1 Clicked");   
       }

</csharp>

Create a windows form with a button the uses your class.

<csharp> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;

namespace WindowsDog {

   public partial class Form1 : Form
   {
       Dog fido;
       
       public Form1()
       {
           InitializeComponent();
           fido = new Dog();
       }
       private void btnBark_Click(object sender, EventArgs e)
       {
           lblBark.Text = fido.Bark();
       }


       public class Dog 
       {
           public string Name;		// the dog's name
           public int Age;			// the dog's age
           public int Weight;			// the dog's weight
           public string BarkSound;	// the sound of the dog's bark
           public Dog()
           {
               BarkSound = "Woof!!!";
           }
           public string Bark()
           {
               return this.BarkSound;
           }
           public void Eat()
           {
               //put eat code here 
           }
       }	
   }

} </csharp>

Home Work

no class on thursday

Try to bind multiple instances of the same object to a web controls.