OOP-technics - Digital Website

Go to content

Main menu:

Computer science > Programming > MonoDevelop

OOP-technics.


OOP = Object-Oriented Programming.
The examples use interfaces, polymorphism,....

An example of OOP-programming:

using System;
using Gtk;

public partial class MainWindow: Gtk.Window
{

   public MainWindow (): base (Gtk.WindowType.Toplevel)
   {
       Build ();
    }

    protected void OnDeleteEvent (object sender, DeleteEventArgs a)
   {
      Application.Quit  ();
 
     a.RetVal = true;
   }
    protected   void OnButton1Clicked (object sender, EventArgs e)
   {
      ((Button)sender).Label    = "Clicked";
      Button newButton = new Button ();
 
     newButton.Label = "New Button";
 
     newButton.Clicked += new EventHandler (newButton_Click);
     //show new created button on screen
      fixed1.Show ();
 
     fixed1.Add (newButton);
 
    newButton.Add (fixed1);
 
    newButton.Show ();
   }
    protected   void newButton_Click (object sender,EventArgs e)
   {
     ((Button)sender).Label ="Clicked!!!";
  }
}

  • Example that create an extra button on your form. Click here:


 

Back to content | Back to main menu