TOPIC: Setting the visibility of controls in an Access
#1515
Setting the visibility of controls in an Access 11 Months ago
I saw another thread with a similar subject but cannot access it for some reason: www.suneido.com/index.php?option=com_fir...p;id=969&catid=3

Anyway, I have an access that has about 30 different "time" fields. A normal user will choose which time fields they want to be presented with, most will never need more that 5 or 6, some less. So, I do not want to go the route of simply disabling them, I want to make them not even visible. An example of some of the fields may be Glider, Flight Engineer, Crew Member. Many people don't fly gliders nor ever fly an aircraft that requires more than the pilot, but some do. The code I have displaying this looks like:

Code:


(GroupBox 'Times' (Border (Grid (
  ((Static '')
   (Center (Static 'Total'))
   (Center (Static 'PIC'))
   // ... all times ...
  )
  ((Static 'Day')
   l_d_total
   l_d_pic
   // ... all times ...
  )
  // ... same for night ...
  // ... totals of day and night (read only)



So, I want to be able to make, say, Flight Engineer Label, Day, Night and Total all
disappear when they do not have that option set. I can do this, however, it seems to not readjust the grid. So, the controls are not visible but the space is still taken.

Any thoughts?

Jeremy
 
 
#1519
Re:Setting the visibility of controls in an Access 11 Months ago
One method is to build your screen layout dynamically - only adding fields if they are wanted.

Grid could be made smart enough to eliminate empty rows or columns.
 
 
andrew
 
#1520
Re:Setting the visibility of controls in an Access 11 Months ago
Is there an example or maybe a short 3-4 line code snippet that shows this?

Jeremy
 
 
#1523
Re:Setting the visibility of controls in an Access 11 Months ago
 
 
#1526
Re:Setting the visibility of controls in an Access 11 Months ago
I have this in my hard coded Controller:

Code:


(Grid (
  ((Static '')
    (Center (Static 'Time'))
    (Center (Static 'PIC'))
    // ... etc ...
  )
)



I am now trying to make it dynamic. My first step was to simply build the existing via code, not really have any thing that turns on and off. I came up with:

Code:


Controls()
  {
  header_ctl = Object()
  header_ctl.Add(StaticControl(''))
  header_ctl.Add(StaticControl('Time'))
  header_ctl.Add(StaticControl('PIC'))
  return  GridControl(header_ctl)
  }



However, that pops up 2 windows, one blank, the other with a Time label. Two windows is not what I was expecting but if two did popup, I would have expected a third one for PIC as well.

Anyway, I am a bit lost now as to what's going on. Basically I am trying to construct a Grid control dynamically, a table of sorts:

Code:


       Total  PIC   SIC   
Day    837.2 [___] [___]
Night  102.3 [___] [___]



The bracketed items being Spinner controls, the rest being Static controls. Once I can create this by code, I'll start to make it dynamic, i.e. not include the whole PIC column if the user doesn't want to track that time.

Thanks for any help,

Jeremy
 
 
#1527
Re:Setting the visibility of controls in an Access 11 Months ago
Hey jeremy.

The GridControl can be a little tricky to build because you have to make sure you get all the Objects right.

Here is some code that might help you get what you are looking for:

Code:

layout = Object()

row = Object()
row.Add(#(Static " "))
row.Add(#(Static "Total"))
row.Add(#(Static "Time"))
row.Add(#(Static "PIC"))
layout.Add(row)

row2 = Object()
row2.Add(#(Static "Day"))
row2.Add(#(Static "837.2"))
row2.Add(#(Spinner))
row2.Add(#(Spinner))
layout.Add(row2)

grid = Object("Grid", layout)
Window(grid)

 
 
#1528
Re:Setting the visibility of controls in an Access 11 Months ago
Thanks jennebelle... that's exactly what I was looking for. Now I can fill out the others, wrap the correct ones in if tags, etc...

Jeremy