Setting AutoAdjustmaxLength in base class


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)Advanced StrataFrame User (866 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I want to set the AutoAdjustMaxLength to true in my Base Class Textbox. Where is the best place to put this and also to ensure it does not fire for Text Boxes that are not bound to a Business Object
Replies
Les Pinter
Les Pinter
StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Hi Aaron,

   I changed the datatype of EventName in the RodeoEventConfiguration table to VarChar(MAX) and rebuilt the business object, and then looked at the generated class code. The MaxLength property of eventName is set to -1 at line 860 of my generated BO class. There's no event that can be handled to intercept that assignment - it's just there.

   I'm looking into how best to detect that in a subclassed StrataFrame textbox's constructor. More on this story as it develops...

Les

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The BO knows about the fields that is managing. I'd think you could test for the field length of the bound field using the FieldLengths dictionary of the bound BO. To make is generic, you could also check out the FieldDbType as well. I.e.



//-- This handles setting the AutoAdjustMaxLength based on if the

//   TextBox is bound to a non-max varchar field

    string boundField = string.Empty;

    if (!string.IsNullOrEmpty(this.BindingField))

    {

      boundField = this.BindingField;

    }

    if ( BusinessObject != null

       && this.BusinessObject.FieldDbTypes[boundField] == DbType.String

       && this.BusinessObject.FieldLengths[boundField] > 0)

        AutoAdjustMaxLength = true;

    }

    else { AutoAdjustMaxLength = false; }




(NOTE: I just typed this out, so there could be syntax/spelling errors, but you should get the idea).



You could run this as suggested in the Enter event or the EnabledChanged event. However, what really is driving this is the binding state. I'd be tempted to sub-class the control, override the BusinessObject and BindingField properties, adding an event like BindingStateChanged and then handle this in that. Of course, better yet would be for this to be built into the framework! BigGrin
Les Pinter
Les Pinter
StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Hi Greg,

   That sure looks interesting, and if you can find a way to get rid of the little red squiggles under FieldDbTypes and FieldLengths (see attached screenshot), I'll give you a cookie<g>.

Les

Attachments
Snap1.gif (178 views, 22.00 KB)
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
My first thought was white out.... Blink



Then I realized that I forgot that the BusinessObject property of IBusinessBindable is BusinessLayerBase and not BusinessLayer. So you need to cast it:



((BusinessLayer)this.BusinessObject).FieldDbTypes[boundField] == DbType.String;



I did mention that I just typed the code in the post and there might be some syntax errors....Blush
Les Pinter
Les Pinter
StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Hi Greg,

   So what kind of cookies do you like...

Les

Les Pinter
Les Pinter
StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)StrataFrame Team Member (95 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Dude, I was the one who didn't think to cast it. Actually, this opens up a whole raft of possible topics for Subclassed StrataFrame controls. I'll credit you liberally, as you deserve. And my wife needs your mailing address for the cookies...

Les

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ger Cannoll - 16 Years Ago
Les Pinter - 16 Years Ago
Aaron Young - 16 Years Ago
Ger Cannoll - 16 Years Ago
Les Pinter - 16 Years Ago
                     Hi Les,

Is there any chance you could modify the textbox...
Aaron Young - 16 Years Ago
Les Pinter - 16 Years Ago
Greg McGuffey - 16 Years Ago
Les Pinter - 16 Years Ago
                     My first thought was white out.... :blink:

Then I realized...
Greg McGuffey - 16 Years Ago
                         Hi Greg, So what kind of cookies do you like... Les
Les Pinter - 16 Years Ago
                         Dude, I was the one who didn't think to cast it. Actually, this opens...
Les Pinter - 16 Years Ago
Russell Scott Brown - 16 Years Ago
             Oatmeal-chocolate chip-walnut. :P
Greg McGuffey - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search