StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Setting MaxLength from BOExpand / Collapse
Author
Message
Posted 06/12/2008 3:55:47 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 11/25/2008 7:55:39 AM
Posts: 473, Visits: 1,955
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

Post #17028
Posted 06/14/2008 9:36:55 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 11/25/2008 7:55:39 AM
Posts: 473, Visits: 1,955
For more detail, see http://forum.strataframe.net/Topic7248-6-1.aspx.

Since I have not been able to get this working, I thought I would try this in the loop to get some more info:

MessageBox.Show(ctrl.GetType().ToString());

Oddly enough, only TWO controls are hit: System.Windows.Forms.ToolStripContainer and MicroFour.StrataFrame.UI.Windows.Forms.GradientHeader.  There are 13 TextEdit boxes on this form.  It is a Standard Form from the StrataFrame toolbox.  Why isn't the form iterating through all of the controls?

In addition, I discovered that the ToolStripContentPanel is not a ContainerControl.  Is that why these controls are not being iterated?

Here is my modified code:

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

Any help would be appreciated,
Bill

Post #17057
Posted 06/14/2008 9:51:55 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 11/25/2008 7:55:39 AM
Posts: 473, Visits: 1,955
I rebuilt the form without the ToolStripContainer.  The code works flawlessly, now.

This troubles me a bit, since I have gobs of forms with this control on it (default) and I will want to add the MaxLength functionality (via base form) to each form that has bound textboxes.  If there is an easier way, please advise.

Thanks,
Bill

Post #17058
Posted 06/14/2008 2:15:12 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 4:29:41 PM
Posts: 367, Visits: 2,446
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

 
Post #17067
Posted 06/14/2008 5:22:38 PM
Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 8:48:41 PM
Posts: 714, Visits: 3,004
Hi Paul, Bill,

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

 
Post #17070
Posted 06/16/2008 7:42:21 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 11/25/2008 7:55:39 AM
Posts: 473, Visits: 1,955
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

Post #17079
Posted 06/16/2008 8:27:14 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 4:29:41 PM
Posts: 367, Visits: 2,446

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 confusing 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 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.  

Post #17081
Posted 06/16/2008 9:07:02 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 11/25/2008 7:55:39 AM
Posts: 473, Visits: 1,955
Super!  Thanks for the info!!

In your arrangements you do the following:

DevEx Control (third-party control)
---AllAppsExtendedControl (base project in a development-wide, separate solution)
------AppSpecificExtendedControl (base project in a application-specific solution)

The only place you would then need to update references would be in the AllAppsExtendedControl solution.

Sprinkle in the appropriate namespaces and voilá!

Do I have that right?
Bill

Post #17082