Subclassing DevEx.TextEdit


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Okay, I tested this and it works :

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;


namespace SFCsharpTest
{

    public class dxTextEditC : MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit
    {

        public dxTextEditC()
        {

            this.initializecomponent();

        }

        private void initializecomponent()
        {

            this.BindingFormat = "c";
            this.Properties.Appearance.Options.UseTextOptions = true;
            this.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            this.Properties.AppearanceDisabled.BackColor = System.Drawing.Color.White;
            this.Properties.AppearanceDisabled.ForeColor = System.Drawing.Color.Black;
            this.Properties.AppearanceDisabled.Options.UseBackColor = true;
            this.Properties.AppearanceDisabled.Options.UseForeColor = true;
            this.Properties.AppearanceDisabled.Options.UseTextOptions = true;
            this.Properties.AppearanceDisabled.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            this.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;

        }

    }
}

I'm attaching a C# project that demonstrates it. 

Attachments
SFCsharpTest.zip (166 views, 55.00 KB)
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I noticed your class is defined as partial. Is there some other part to it? What happens if you just translate my code into C# and paste directly into a class.cs ?







Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I'm going to let Greg or Trent step in on this one. Not sure if this works differently in C#.



Looks pretty solid in VB. The code I posted is the entirety of the code in my dxTextEditC.vb class.



When dropped on a form from the toolbox I see all the properties set by default ( including being bolded ) as if I had manually set them as dropping the SF control on.



Are you subclassing the SF wrapper or the Dx control directly?

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I just tried this approach (add a constructor with an initialization method) and the control at design-time does not set the properties according to the specifications within the init method. How are you getting this thing to work? I went back to the drawing board on my control (mostly to try out some new ideas), but have gotten back to the same place that I was earlier in the week...setting these properties in a layout method or attaching them to an event (e.g. OnBindingContextChanged).
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
(addendum )



Here's the properties I added to get the TextEdit control working just the way I want it for 2 decimal numbers :





Me.Properties.EditFormat.FormatString = "000,000,000.00"

Me.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric

Me.Properties.Mask.ShowPlaceHolders = False

Me.Properties.Mask.UseMaskAsDisplayFormat = True





BTW - the subclassed control is created from a humble Class, not a component or user control or DevExControl or whatever else might look tempting in the templates Smile



You will probalby need to close all forms you may have open and rebuild both the UI Class library and the project using the control in order to see what you need in the toolbox.





Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Thanks to Bill and Greg, here's the finished dxTextEdit.vb I was trying to get.



This subclasses the Strataframe DevEx wrapper for the DevExpress TextEdit control which is in the XtraEditors 9.3 now available free from DevExpress. In this case I have set default properties to show the textbox normally when disabled, to treat its display and editing as numeric ( though in my usage I am binding to a character field ) and to right align the numbers, both for display and editing. I will probably further refine this as I learn more about how I want to mask it, but this will demonstrate how to simply take advantage of these controls and subclass variations to save some time setting a lot of properties ( this control is being used 50+ times on a form )



From what Greg said the C# implementation may be different and I will leave that to those better qualified.



Note: I have this control in a UI project of my own subclasses of controls. You need to reference



DevExpress.Data.v9.3

DevExpress.Utils.v9.3

DevExpress.Xtra.Editors.v9.3



in your project.





Imports System

Imports System.Data

Imports System.Drawing

Imports System.Windows.Forms





Public Class dxTextEditC

Inherits MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit



Public Sub New()



Me.initializecomponent()



End Sub



Private Sub initializecomponent()



Me.BindingFormat = "c"

Me.Properties.Appearance.Options.UseTextOptions = True

Me.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far

Me.Properties.AppearanceDisabled.BackColor = System.Drawing.Color.White

Me.Properties.AppearanceDisabled.ForeColor = System.Drawing.Color.Black

Me.Properties.AppearanceDisabled.Options.UseBackColor = True

Me.Properties.AppearanceDisabled.Options.UseForeColor = True

Me.Properties.AppearanceDisabled.Options.UseTextOptions = True

Me.Properties.AppearanceDisabled.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far

Me.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric

Me.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric



End Sub



End Class

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Heh heh...you betcha! I am opening the source code, as we speak. I'll be making the change for my own extended control. Easy-peasy. Just thinking about that future developer... Cool
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
There is no reason for us to do it when you guys are making the change right now your self. I really don't mind adding it, but no reason to wait on us. Just open the SF source code to see our logic there and then transpose that over to TextEdit control. Smile
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Nope...it is NOT on the TextEdit control. Alas!

The control was the MicroFour.StrataFrame.UI.Windows.Forms.Textbox.



Got myself all worked up for nothing.



SF, do you think you could add that little nugget into the extended TextEdit control?



Thanks,

Bill
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)StrataFrame VIP (1.2K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Dude.



Just saw it.



AutoAdjustMaxLength property on the SF-extended DevEx TextEdit control.



Testing now.



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