Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating Classes
Message
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Divers
Thread ID:
01126166
Message ID:
01126212
Vues:
20
>In Visual foxpro it was quite normal to create an object based on another object
>
>For instance An OK button based on a button that shut down that form
> or A Form with all the necessary buttons and other controls to carry out a task that is similar to other tasks
>
>You would then drop that object on whatever was required and it would work with very little programming
>
>Is this a standard OOPs practice available in Dot Net or am I barking(mad) upthe wrong tree
>
>Richard

Richard,
Ohh yes it is available in .Net and it is adviced to be used. Below is an example how you can create a OK button class which is based of the button control:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace MyNamespace
{
	public class OkButton : Button
	{
		private System.ComponentModel.IContainer components = null;


		public override string Text
		{
			get { return base.Text; }
			set { ;}
		}

		public override DialogResult DialogResult
		{
			get { return base.DialogResult; }
			set { ;}
		}

		public OkButton()
		{
			base.Text = "OK";
			base.DialogResult = DialogResult.OK;
			base.Size = new Size(75, 23);

		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose(disposing);
		}
	}
}
HTH

Einar
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform