Setting MaxLength from BO


Author
Message
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
Here is my code snippet:

private void SetAllMaxLengths(ContainerControl pContainer)
{
    MicroFour.StrataFrame.UI.Windows.Forms.DevEx.
TextEdit mBox = null;
   
foreach (Control ctrl in pContainer.Controls)
    {
        mBox = ctrl
as MicroFour.StrataFrame.UI.Windows.Forms.DevEx.TextEdit;
       
if (mBox!=null)
        {
            mBox.Properties.MaxLength = ((
BusinessLayer)mBox.BusinessObject).FieldLengths[mBox.BindingField];
        }
    }
}

I pass my form to the method.  It should iterate the controls and set the MaxLength property of each TextEdit control to the FieldLength of the bound field.  It is not doing that.  What am I doing wrong?

Thanks,
Bill

Replies
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Bill,

You could do it in your textedit baseclass rather than form base class. Here is a really basic example there may be a better event to use rather than the enter event.

Paul

Public Class MyTextBox

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

Public Sub New()

initializecomponent()

End Sub

Private Sub initializecomponent()

End Sub

Private Sub MyTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Enter

If Not Me.BusinessObject Is Nothing AndAlso Me.BindingField.Equals(String.Empty) Then

Me.Properties.MaxLength = CType(Me.BusinessObject, MicroFour.StrataFrame.Business.BusinessLayer).FieldLengths(Me.BindingField)

End If

End Sub

End Class

 
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Paul, Bill,

Thanks for the ideas, I will try to implement Paul's class for the textbox and see how it works.

Edhy Rijo

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
Great idea, Paul...thanks!

A few, little housekeeping questions...how do handle the extended controls?  Do you create them in the current project that needs them?  Separate project?  Separate solution?  What naming conventions do you use for the extended controls?

Also, since you extend various controls, how do you handle versioning, that is, keeping track of these items as various parties update their products?

Thanks!
Bill

Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K

A few, little housekeeping questions...how do handle the extended controls?  Do you create them in the current project that needs them?  Separate project?  Separate solution?  What naming conventions do you use for the extended controls?

I created a seperate solution called Subclassed Controls. I have multiple namespaces such as ActionLabor.SubclassedControls.DevEx ActionLabor.SubclassedControls.StrataFrame etc. I only add logic here that I want throughout all my applications.

Then in whatever solution I am working in I always create a project called Base which houses application specific base clasess and logic etc. I then sublclass the subclassed controls from earlier and add any application specific logic.

ActionLabor.Payroll.Base.SubclassesControls.DevEx --> inherits from ActionLabor.SubclassedControls.DevEx

As far as naming if you use namespacing you could actually name them the same however that can get confusingBigGrin I prefix mine like ALBASETextEdit and ALPayrollTextEdit because it makes it easier for me to remember.

Also, since you extend various controls, how do you handle versioning, that is, keeping track of these items as various parties update their products?

The compiler will tell you Tongue Obviously if I download a new version of Dev express and un-install the current version you will need to update references in each project that has a reference to the old version.  

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