﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Subclassing a control</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 04:51:55 GMT</lastBuildDate><ttl>20</ttl><item><title>Subclassing a control</title><link>http://forum.strataframe.net/FindPost29816.aspx</link><description>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:&lt;br/&gt;&lt;br/&gt;I have a &lt;font color=#880088&gt;MyTextBox&lt;/font&gt; 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.&lt;br/&gt;&lt;br/&gt;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 &lt;font color=#cc1188&gt;MYTExtBox&lt;/font&gt; above.&lt;br/&gt;&lt;br/&gt;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</description><pubDate>Tue, 05 Apr 2011 04:27:00 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Subclassing a control</title><link>http://forum.strataframe.net/FindPost29832.aspx</link><description>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</description><pubDate>Tue, 05 Apr 2011 04:27:00 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Subclassing a control</title><link>http://forum.strataframe.net/FindPost29821.aspx</link><description>It appeared I did not have some of the DEv Express references included. I included these and can now see the &lt;font face=Consolas&gt;this.backColor&amp;nbsp;&amp;nbsp;base.OnLeave property and events etc so I can include the original SubClass functionality.&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face=Consolas&gt;However, still cant see this.AutoAdjustMaxLength property. I need this to automatically set all controls (All textBoxes) to MaxLength&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font face=Consolas&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&amp;nbsp;</description><pubDate>Thu, 31 Mar 2011 09:55:24 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Subclassing a control</title><link>http://forum.strataframe.net/FindPost29820.aspx</link><description>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:&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;&lt;font color=#0000ff size=2 face=Consolas&gt;[quote]public class Textbox : MicroFour.StrataFrame.UI.Windows.Forms.Textbox&lt;br/&gt;{&lt;br/&gt;private System.Drawing.Color originalBackgroudColour;&lt;br/&gt;protected override void OnEnter(EventArgs e)&lt;br/&gt;{&lt;br/&gt;//-- Run Base Class Code&lt;br/&gt;base.OnEnter(e);&lt;br/&gt;//-- Save away original background color&lt;br/&gt;this.originalBackgroudColour = this.BackColor;&lt;br/&gt;　&lt;br/&gt;//-- Set fields to be the maximum length of the database fields&lt;br/&gt;//-- For Memo (VarChar(Max) check for Mutiline..assumes Multiline is on for VarChar(Max) though&lt;br/&gt;if (this.BusinessObject == null || this.Multiline == true )&lt;br/&gt;{&lt;br/&gt;this.AutoAdjustMaxLength = false; &lt;br/&gt;}&lt;br/&gt;else&lt;br/&gt;{&lt;br/&gt;this.AutoAdjustMaxLength = true; &lt;br/&gt;}&lt;br/&gt;//-- Define the background color for the control.. maybe extend this to use a property later&lt;br/&gt;this.BackColor = Color.Aqua;&lt;br/&gt;}&lt;br/&gt;protected override void OnLeave(EventArgs e)&lt;br/&gt;{&lt;br/&gt;//-- Run the Base Code for the textbox&lt;br/&gt;base.OnLeave(e);&lt;br/&gt;//-- Reset back color to the default&lt;br/&gt;this.BackColor = this.originalBackgroudColour;&lt;br/&gt;}&lt;br/&gt;} // End textBox[/quote]&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;font color=#008000 size=2 face=Consolas&gt;&lt;br/&gt;&lt;br/&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2 face=Consolas&gt;&lt;font size=2 face=Consolas&gt;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&amp;nbsp;&amp;nbsp; this.backColor&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.AutoAdjustMaxLength&amp;nbsp; base.OnLeave&lt;/font&gt;&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;I was expecting these to be the same , is the TextEdit not a subClass somewhere along the line of the SF textBox ?&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;(Charles, I had a look at your code but having a bit of difficulty transalting VB to c#)&lt;/font&gt;&lt;br/&gt;&lt;br/&gt;&lt;font size=2 face=Consolas&gt;&lt;/font&gt;&amp;nbsp;</description><pubDate>Thu, 31 Mar 2011 06:49:10 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Subclassing a control</title><link>http://forum.strataframe.net/FindPost29819.aspx</link><description>Hi Charles. Many tahnks for replying.&lt;br/&gt;&lt;br/&gt;I will down load and have a look.</description><pubDate>Thu, 31 Mar 2011 04:58:58 GMT</pubDate><dc:creator>Ger Cannoll</dc:creator></item><item><title>RE: Subclassing a control</title><link>http://forum.strataframe.net/FindPost29818.aspx</link><description>I subclass the SF Devex control so as to have a textbox formatted for currency, one for integers, and one for text.&amp;nbsp; 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)&lt;br/&gt;&lt;br/&gt;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.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;I have these in their own project and then use that project in all my SF VB apps.&amp;nbsp; &lt;br/&gt;&lt;br/&gt;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.&amp;nbsp; &lt;br/&gt;&lt;br/&gt;Let me know how it works for you.&amp;nbsp; &lt;br/&gt;</description><pubDate>Wed, 30 Mar 2011 15:34:39 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item></channel></rss>