Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OK, I give up
Message
De
28/06/2004 09:44:56
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00917740
Message ID:
00917933
Vues:
14
This message has been marked as a message which has helped to the initial question of the thread.
But George, I'm not saying they *can't* be subclassed, just not visually. And I'm not saying I couldn't think of a reason to sub-class textboxes or labels, just that I couldn't think of a good reason that they had to be visually sub-classed. Just create one class library to put all your sub-classed simple objects in. It's easy as pie. As Kevin said, I've got several posts on that subject here, but rather than search for them, cuz I'm lazy, I'll just re-post it here (copy/paste from my saved samples is easier <g>).
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace MyCompany.WinUI.MyClasses
{
	public class MyComboBox : System.Windows.Forms.ComboBox
	{
		// code here
	}

	public class MyTextBox : System.Windows.Forms.TextBox
	{
		// code here
	}

	public class MyButton : System.Windows.Forms.Button
	{
		// code here
	}
}
~~Bonnie


>>Hey Bonnie,
>>
>>Are you talking about Web controls or WinForm controls? I'll let the Web experts answer the first one.
>
>WinForms.
>
>>For WinForm controls, simple controls such as buttons or labels can't be visually designed. I'm not even sure *why* you'd need to visually design a button. Can you give me an example of why you're trying to do this?
>
>I'll give you a couple of examples.
>
>First, assume a label. By sub-classing the label and giving a a given font name and size, all labels inherit these properties. Real world example can be seen in Win9x versus Win2K. In the former the default font was MS Sans Serif. In the latter it's Tahoma. By sub-classing the label, if I wanted my application to match defaults, I just have to change the font name and re-compile. Every label then is set to the new font.
>
>More complex would be say a text box. We use a number of 5 alpha/numeric character fields (I can think of at least 4 different types of these off the top of my hear). These should always be entered in upper case. In VFP, I can create a class and use it whenever I need it.
>
>I know, copy and paste...grumble
>
>>However, composite UserControls or Forms *can* be visually designed, simply by specifying "Add Inherited Form" or "Add Inherited Control" when adding a new class to your project.
>
>This I was aware of, but thanks.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform