Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jun 19, 2015 at 03:19 PM

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

    Abdallah

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 19, 2015 at 03:19 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 19, 2015 at 03:26 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2015 at 09:22 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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