Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: Dan Baker
  Where is Dan Baker?
 Effort of the Poconos
 Pennsylvania - United States
 Dan Baker
 Tags
Subject: RE: Simplify column style creation in cnt
Thread ID: 416471 Message ID: 416475 # Views: 60 # Ratings: 2
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Tuesday, December 30, 2014 4:58:43 AM         
   


> Foxites:
>
> I am creating a container at run-time that has multiple columns in it.
>
> Each column is a commandbutton — and each commandbutton column
> is styled differently.  
>
> So my current idea is to create a data object for each column to store
> the property settings (30 or 40 each).
>
> But as you can see from the sample object creation method below, the
> creation of column properties gets too complicated with lots of
> repetition in the code.
>
> So what should be my strategy?  Is it best to store all the properties
> in a table or array?  How can I simplify things so that I don't have to
> repeat (and hard code) the properties several times?
>
> Thanks, Dan B.
>
>
*
> * Create multiple columns in a container - each column needs to 
> *                                          be styled differently 
> *
> *          the container    the objects holding each column's properties 
> LPARAMETERS oContainer,     o1, o2, o3, o4, o5, o6... oN
> 
> WITH oContainer
> 
> SELECT * FROM country INTO Junk
> 
> nTop = 0
> j = 1
> 
> SCAN 
> 
>   k= TRANSFORM(j)
> 
>   FOR p = 1 TO N
>     q = TRANSFORM(m.p)
>     = EVAL( [.Newobject('_]+m.q+[cmd_]+m.k+[','CommandButton')] )
>     oControl = EVALUATE( '._'+m.q+'cmd_'+m.k )
>     
>     WITH oControl
>     DO case
>     CASE p = 1  && Column 1
> 
>       .Left    = o1.cmdMarginLeft      &&  <-- hard coded properties
>       .Top     = o1.cmdMarginTop + m.nTop
>       .Width   = o1.cmdWidth    
>       .Caption = Junk.country
>     
>     CASE p = 2  && Column 2
> 
>       .Left    = o2.cmdMarginLeft      &&  <-- hard coded properties
>       .Top     = o2.cmdMarginTop + m.nTop
>       .Width   = o2.cmdWidth 
>       .Caption = Junk.region     
> 
>     CASE p = N  && Column N
>       ...
>     
>     ENDWITH && oControl
>     
>   ENDFOR   
>   
>   nTop = m.nTop + 20
> 
> ENDSCAN     
> 



Maybe something like this instead?

With oControl
	.Left = Evaluate('o'+Transform(p)+'.cmdMarginLeft')
	.Width = Evaluate('o'+Transform(p)+'.cmdWidth')
	.Top = = Evaluate('o'+Transform(p)+'.cmdMarginTop')+ m.nTop
	.Caption = Icase(p=1,junk.country,p=2,junk.Region........)


ENTIRE THREAD

Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 2:47:29 AM
RE: Simplify column style creation in cnt Posted by Jun Tangunan @ 12/30/2014 4:58:43 AM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 12:46:00 PM
RE: Simplify column style creation in cnt Posted by Mike Yearwood @ 12/30/2014 6:51:21 PM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 7:15:44 PM
RE: Simplify column style creation in cnt Posted by Mike Yearwood @ 12/30/2014 9:21:00 PM
RE: Simplify column style creation in cnt Posted by Jun Tangunan @ 12/30/2014 9:51:17 PM
RE: Simplify column style creation in cnt Posted by Dan Baker @ 12/30/2014 10:59:55 PM