Subclassing DevEx.TextEdit


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K 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
Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 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?

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 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
Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 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 (113 views, 55.00 KB)
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Thanks for working this out with me. Here is the code that I am using:





using MicroFour.StrataFrame.Business;

using System;

using System.Data;

using System.Drawing;



namespace Aspire.SubclassedControls.DevEx

{

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

{

public TextEdit()

{

InitializeControl();

}



private void InitializeControl()

{

if ((BusinessObject != null) && (BindingField != String.Empty))

{

Properties.AppearanceDisabled.BackColor = Color.FromName("Info");

Properties.AppearanceDisabled.ForeColor = Color.FromName("InfoText");

Properties.AppearanceReadOnly.BackColor = Color.FromName("Info");

Properties.AppearanceReadOnly.ForeColor = Color.FromName("InfoText");

if (((BusinessLayer)BusinessObject).FieldDbTypes[BindingField] == DbType.AnsiString)

Properties.MaxLength = ((BusinessLayer)BusinessObject).FieldLengths[BindingField];

}

}

}

}





Looks quite similar to your's, eh?

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
btw, how do you get your posted code to have the indentation...I knew once how to do it. I've forgotten.
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)Advanced StrataFrame User (892 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I'm calling initializecomponent and you're calling initializecontrol ?



I just copied the code from my class in vs and pasted between the codesnippet ifcodes. Get it indented in VS is an IDE options thing.

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I pulled the appearance properties out of the if-statement. That should take care of that piece of the puzzle. Silly me.



As far as the copy/paste routine....yup, that is what I do. I lose all of the indentation, though.



Perhaps, it a Google Chrome thing.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
After all of the fun, I have the following functioning code. It is not much different than where I started before attempting to recreate the SF code.



using MicroFour.StrataFrame.Business;

using System;

using System.Data;

using System.Drawing;



namespace Aspire.SubclassedControls.DevEx

{

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

{

public TextEdit()

{

InitializeControl();

}



private void InitializeControl()

{

Properties.AppearanceDisabled.BackColor = Color.FromName("Info");

Properties.AppearanceDisabled.ForeColor = Color.FromName("InfoText");

Properties.AppearanceReadOnly.BackColor = Color.FromName("Info");

Properties.AppearanceReadOnly.ForeColor = Color.FromName("InfoText");

}



protected override void OnBindingContextChanged(EventArgs e)

{

base.OnBindingContextChanged(e);

if ((BusinessObject != null) && (BindingField != String.Empty))

{

if (((BusinessLayer)BusinessObject).FieldDbTypes[BindingField] == DbType.AnsiString)

Properties.MaxLength = ((BusinessLayer)BusinessObject).FieldLengths[BindingField];

}

}

}

}


Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I am trying to SubClass the DevEx TextEdit control and use the AutoAdjustMaxLength property thats in the SF TextBox.

If this is now included as standard, could someone point me in the right direction, if not , some pointers to where the code is in the SF Source Code, or if somebody has already done it in C#, that would be very useful 
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