﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Field sizes</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 13:47:13 GMT</lastBuildDate><ttl>20</ttl><item><title>Field sizes</title><link>http://forum.strataframe.net/FindPost7248.aspx</link><description>This is more out of curiosity but also lends itself to efficiency.&amp;nbsp; When creating the BO's using the Business Object Mapper, shouldn't there be some way of creating a property with MaximumSize?&amp;nbsp; This way when creating the UI, I do not have to keep referring to our SQL Schema to find out the size of each field.&amp;nbsp; We have over 540 tables in our schema, more tables and fields being added by the DBA frequently so I cannot keep track of the sizes in my head.&lt;/P&gt;&lt;P&gt;So whether the field should accept 1 character or 5,000, it would be easier to type:&lt;/P&gt;&lt;P&gt;MyTextField.MaximumSize = Me.MyBO1.Field.MaximumSize - or if you look at my enhancement idea for an automatic screen builder wizard, this metadata could be used to set the property automagically.&lt;/P&gt;&lt;P&gt;You have the data in the DDT and even if you directly import into the BOM, all you need is an additional MaxSize field listed here to support this feature.&amp;nbsp; &lt;/P&gt;&lt;P&gt;So, out of curiosity, is this something that "might" be supported in the future?&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Mon, 05 Mar 2007 09:00:11 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7302.aspx</link><description>I assumed that your code was going to be in a class... therefore Shared (in fact, when you put code in a module, .NET compiles the module as a class and then adds all of the methods to it as Shared :)).&amp;nbsp; As for the FieldLengths not being a property, you will need to change that line to:&lt;/P&gt;&lt;P&gt;box.MaxLength = CType(box.BusinessObject, BusinessLayer).FieldLengths(box.BindingField)</description><pubDate>Mon, 05 Mar 2007 09:00:11 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7301.aspx</link><description>Thanks Ben.&amp;nbsp; However, when I copy this code into my tools module, I get two errors:&lt;/P&gt;&lt;P&gt;1. Shared is not allowed in a module &amp;lt;--- I removed the Shared&lt;/P&gt;&lt;P&gt;2. box.BusinessObject.FieldLengths(box.BindingField) - FieldLengths is not a member of MicroFour.StrataFrame.Business.BusinessLayerBase &amp;lt;-- isn't FieldLengths a property of the IBusinessBindable interface?&amp;nbsp; If so, how do I cast that into your code example?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Mon, 05 Mar 2007 07:27:15 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7287.aspx</link><description>No, reflection is going to slow you down tons... your best bet is probably to do a TryCast... it's much faster than catching any InvalidCastExceptions and a little faster than testing the TypeOf or GetType() of something.&amp;nbsp; And you'll also need to call it recursively (because not all of the textboxes are going to be in the root Controls collection).&lt;/P&gt;&lt;P&gt;Public Shared Sub SetAllMaxLengths(ByVal container As ContainerControl)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim box As MicroFour.StrataFrame.UI.Windows.Forms.TextBox&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim container2 As ContainerControl&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each ctrl As Control In container.Controls&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; box = TryCast(ctrl, MicroFour.StrataFrame.UI.Windows.Forms.TextBox)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; If box IsNot Nothing Then &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; box.MaxLength = box.BusinessObject.FieldLengths(box.BindingField)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container2 = TryCast(ctrl, ContainerControl)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If container2 IsNot Nothing Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SetAllMaxLengths(container2)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;BR&gt;&lt;BR&gt;End Sub &lt;/P&gt;&lt;P&gt;You can then call this method from within any form by just passing Me as a reference to the parameter (because a form is a ContainerControl).</description><pubDate>Fri, 02 Mar 2007 16:59:41 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7280.aspx</link><description>Ben,&lt;/P&gt;&lt;P&gt;I think I am close to a generic solution that I can call from any StrataFrame form.&amp;nbsp; However,&amp;nbsp;I cannot for the life of me figure out&amp;nbsp;what the proper AS&amp;nbsp;"Control" to use from SF's object library.&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; SetMaxLengths(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; MyForm &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.UI.Windows.Forms.BaseForm, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; BO &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Business.BusinessLayer)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Each&lt;/FONT&gt;&lt;FONT size=2&gt; MyControl &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; Control &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;In&lt;/FONT&gt;&lt;FONT size=2&gt; MyForm.Controls 'HERE the AS CONTROL needs to be&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;replaced with a more specific type of control from SF library since .BindingField &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and .MaxLength are none standard&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp; If&lt;/FONT&gt;&lt;FONT size=2&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;TypeOf&lt;/FONT&gt;&lt;FONT size=2&gt; MyControl &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Is&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.UI.Windows.Forms.Textbox) &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; MyControl.BindingField &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;MyControl.MaxLength = BO.FieldLengths(MyControl.BindingField)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;Next&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Or is there a better way with reflection?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Ben&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 02 Mar 2007 13:35:41 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7279.aspx</link><description>Ben,&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp; That worked like a charm.&amp;nbsp; Hopefully one of these days I will be as well versed in .NET as you :cool:&lt;/P&gt;&lt;P&gt;Now to make it generic so I can call it whenever initializing a form ;)&lt;/P&gt;&lt;P&gt;Ben</description><pubDate>Fri, 02 Mar 2007 12:53:35 GMT</pubDate><dc:creator>Ben Kim</dc:creator></item><item><title>RE: Field sizes</title><link>http://forum.strataframe.net/FindPost7263.aspx</link><description>We do not currently have plans to implement a "MaxSize" property on the business object... however, we already have a FieldLengths property... For string fields, it will contain the length of characters that the field can contain (i.e. for VarChar(150), the value will be 150).&amp;nbsp; For other data types, it will be 0 (and it's part of the partial class, so it gets updated when you rebuild the partial class).&amp;nbsp; As I said, though, we don't have plans to automatically set the MaximumLength property on a textbox to the specified value.</description><pubDate>Fri, 02 Mar 2007 08:57:36 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>