Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Custom Control help
Message
De
27/06/2007 00:52:32
 
 
À
25/06/2007 14:54:34
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Versions des environnements
Environment:
VB 8.0
Divers
Thread ID:
01235431
Message ID:
01235913
Vues:
8
I was going to suggest overriding the ReadOnly property, as some examples floating around here lately were showing with overriding the Font or BackColor properties. Unfortunately though, the ReadOnly property is not overridable. So, instead, create your own property and call it SetReadOnly, or something similar. We do that with our controls for the Enabled property, since it's not overridable either. Sorry for the C# code:
public class MyTextBox : System.Windows.Forms.TextBox
{
	private bool m_SetReadOnly;

	public MyTextBox
	{
		this.m_SetReadOnly = true;
	}

	[DefaultValue(true)]
	public bool SetReadOnly
	{
		get {return this.m_SetReadOnly;}
		set
		{
			this.m_SetReadOnly = value;
			this.ReadOnly = value;
		}
	}
}
~~Bonnie



>OK, now it is my turn to ask a question about custom controls... *ducks*
>
>Hopefully this is an easy one, as I think I am just misunderstanding what I am supposed to do. I created a class called MyTextBox, and inherited from System.Windows.Forms.TextBox, and I could place my custom control on the form. Now, to play around with it I tried to set some defaults, specifically setting ReadOnly = True. It didn't seem to carry forward into the control I dropped.
>
>Here is my code:
>
>Public Class MyTextBox
>    Inherits System.Windows.Forms.TextBox
>
>    Public Sub New()
>
>        MyBase.New()
>
>        Me.ReadOnly = True
>
>    End Sub
>
>End Class
>
>
>Any guidance? 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