Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Yeah, I'd call the base class constructor in most cases. BTW, this does work when I try it with a SF textbox (I set backcolor, Text and IgnoreManageReadonlyState). There was some issues with some properties not immediately showing up, but they were there. Now, where this could get exiting is if the DevX control is messing with stuff after the control is constructed, which it sounds like it is, hence the need to figure out where you can finally manipulate properties without DevX stomping on those changes. Anyway, it sounds like in this case, you have to use the layout event.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
I just made a minor change to the class...the properties for the back and fore colors were not showing up in the designer, so I did replaced the TextEdit_Layout method with this: protected override void OnLayout(LayoutEventArgs levent)
{
base.OnLayout(levent);
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");
}
} That works nicely.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
...the DevX control is messing with stuff after the control is constructed... Yup...I think it has to do with the support for application themes.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
I played around with my code a little more. I could not get the properties to behave in the constructor. The BusinessObject is always null at that point. So, I tweaked things and found a better method to perform the rituals. Here is the refined code:
using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace Aspire.SubclassedControls.DevEx
{
public partial class TextEdit : MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit
{
public TextEdit()
{
InitializeComponent();
}
private void TextEdit_BindingContextChanged(object sender, EventArgs e)
{
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 (((MicroFour.StrataFrame.Business.BusinessLayer)BusinessObject).FieldDbTypes[BindingField] == DbType.AnsiString)
Properties.MaxLength = ((MicroFour.StrataFrame.Business.BusinessLayer)BusinessObject).FieldLengths[BindingField];
}
}
}
}
It is just a tad cleaner and places the changes at a point where it is better handled...someday my code may be changing the binding (doubt it, but one never knows). Doing it this way I won't have to think about the sub-classed TextEdit control.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Dude.
Just saw it.
AutoAdjustMaxLength property on the SF-extended DevEx TextEdit control.
Testing now.
|
|
|
Bill Cunnien
|
|
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
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
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.
|
|
|
Bill Cunnien
|
|
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...
|
|
|
Charles R Hankey
|
|
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
|
|
|
Charles R Hankey
|
|
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 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.
|
|
|