Subclassing a control


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I want to subclass a control , but get the functionality from two parent classes, and am not sure whats the best way to go about this. Scenario is as follows:

I have a MyTextBox which suclasses the SF textBox and adds in some funtionality like for instance highlighting the textBox if it has focus, so that it stands out. This is working fine.

Now I want to start using a 'MyTextBoxNumeric' text Box , which will be SubClassing the DeveExpress Sf Wrapped textEdit box, but I also want the funtiionality that is in MYTExtBox above.

Now in Dot net (as far as I am aware) I cannot subClass from two different classes, so am wondering whats the best way to do this, without copying and pasting too much code
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I subclass the SF Devex control so as to have a textbox formatted for currency, one for integers, and one for text.  This will give you the idea. (don't remember why one has a resx file - probably unnecessary, but you just need to see the code anyway)

I can't see to get the forum html to put my code on separate lines so I will just zip and attach my three classes.


I have these in their own project and then use that project in all my SF VB apps. 

As you probably know, you can go to the code behind page of your window and do a global replace for the type for textboxes, so it is a simple matter to convert a window to your new Devex controls. 

Let me know how it works for you. 

Attachments
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Charles. Many tahnks for replying.

I will down load and have a look.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Trying to subclass the NF.SF.UI.Windows.Forms.Devex.textedit control and include same functionality as I had when I subclassed the SF TextBox. My original Class as follows:

public class Textbox : MicroFour.StrataFrame.UI.Windows.Forms.Textbox
{
private System.Drawing.Color originalBackgroudColour;
protected override void OnEnter(EventArgs e)
{
//-- Run Base Class Code
base.OnEnter(e);
//-- Save away original background color
this.originalBackgroudColour = this.BackColor;
 
//-- Set fields to be the maximum length of the database fields
//-- For Memo (VarChar(Max) check for Mutiline..assumes Multiline is on for VarChar(Max) though
if (this.BusinessObject == null || this.Multiline == true )
{
this.AutoAdjustMaxLength = false;
}
else
{
this.AutoAdjustMaxLength = true;
}
//-- Define the background color for the control.. maybe extend this to use a property later
this.BackColor = Color.Aqua;
}
protected override void OnLeave(EventArgs e)
{
//-- Run the Base Code for the textbox
base.OnLeave(e);
//-- Reset back color to the default
this.BackColor = this.originalBackgroudColour;
}
} // End textBox




Now when I try t replicate this , with the TextEdit, some of the properties and events dont seem to be there e.g. base.OnEnter   this.backColor      this.AutoAdjustMaxLength  base.OnLeave

I was expecting these to be the same , is the TextEdit not a subClass somewhere along the line of the SF textBox ?

(Charles, I had a look at your code but having a bit of difficulty transalting VB to c#)

 
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
It appeared I did not have some of the DEv Express references included. I included these and can now see the this.backColor  base.OnLeave property and events etc so I can include the original SubClass functionality.

However, still cant see this.AutoAdjustMaxLength property. I need this to automatically set all controls (All textBoxes) to MaxLength



 
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)Advanced StrataFrame User (632 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I've seen how to do this from another thread....need to copy code from SF source and replicate... amny thanks for all help given
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search