cancel
Showing results for 
Search instead for 
Did you mean: 

In the open event, How do make 5 columns invisible without listing each one

Former Member
0 Kudos

I never knew how to do this kind of logic and it really comes into play a lot. Like to learn the right way finally.

Example

LISTING OUT EACH ONE METHOD

dw_1.Object.t1.Visible=0

dw_1.Object.t2.Visible=0

dw_1.Object.t3.Visible=0

dw_1.Object.t4.Visible=0

dw_1.Object.t5.Visible=0

DESIRED METHOD(I know this does not work)

string ls_test

FOR i = 1 to 5

    ls_test = "dw_1.Object.t" + String(i) + ".Visible=0"

NEXT

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

If you want to stay with dot notation then the following might be the maximum possible:

int colnum
dwobject dwobjects[]

...

dwobjects[]= {dw_main.object.#1, dw_main.object.#2, dw_main.object.#3, dw_main.object.#4, dw_main.object.#5}

for colnum = 1 to 5
dwobjects[colnum].visible = 0
next

Former Member
0 Kudos

Note the statement that didn't fitted on a line in this forum:

dwobjects[]= {dw_main.object.#1, dw_main.object.#2, dw_main.object.#3, dw_main.object.#4, dw_main.object.#5}

You can also write functions for it with the dwobject array and the datawindow as arguments and different number of columns so that you have to write it only ones.


Can't remember a direct way of getting the list of columns .

int colnum
dwobject dwobjects[]

...

dwobjects[]= gfcolumns_1_to_5(dw_main)

for colnum = 1 to 5
  dwobjects[colnum].visible = 0
next

gfcolumns_1_to_5 would return  {dw_main.object.#1, dw_main.object.#2, dw_main.object.#3, dw_main.object.#4, dw_main.object.#5}

Ben

Former Member
0 Kudos

Hi Philip;

  You can do it Brad's way ... however - there is another way:

1) create a computed SQL column (ie:  cc_visible_flag)

2) Add an expression to the visible property of object that need to perform hide/show processing

     =>  IF ( cc_visible_flag ="Y", 1, 0)

3) Now just use a DC.SetItem (row, "cc_visible_flag", "<Y/N>") and let the DWO handle columns, labels, related computed values, CB's, lines, etc

This encapsulates the whole DWO's hide/show processing.  

Food for thought.    

Regards ... Chris

tobias
Explorer
0 Kudos

Chris should also mention, that his opportunity might be the fastest at runtime... 😉

Former Member
0 Kudos

You'll want to use the Modify method on the datawindow:

string ls_test

FOR i = 1 to 5

    ls_test = dw_1.Modify( "t" + String(i) + ".Visible=0")

NEXT

Former Member
0 Kudos

use dw_1.Modify("t" + string (i) + "Visible='0'"

Abdallah