IsA Container Control

  1. 6 days ago

    Clifford C

    Jun 27 Port Angeles, Washington

    I'm attempting to hide all newCC container controls in a window and then create a new one. Although I have several in the window the container controls are in none will hide or will reach the break. I would it's my code that is a problem:
    Index as integer is sent to this method.

    var newCC(6) As ContainerControl1
    newCC(index) = new ContainerControl1
    var i as integer
    
    for i =(controlcount-1) downto 0 
      if control(i) isA ContainerControl1 then 
        break
        newCC(i).hide
      end
    next i
    newCC(index).EmbedWithin(Self, 50, 100)

    welcome to the wonderful world of container controls
    they are a tad odd in that while you create a new instance of your specific container control when iteratiing the controls you have to look for EmbeddedWindowControl instances

    var newCC(6) As ContainerControl1
    newCC(index) = new ContainerControl1
    var i as integer
    
    for i =(controlcount-1) downto 0 
      if control(i) isA EmbeddedWindowControl then 
        break
        newCC(i).hide
      end
    next i
    newCC(index).EmbedWithin(Self, 50, 100)
    
  2. Norman P

    Jun 27 Testers, Xojo Pro Answer outside admiring the sunshine,...

    welcome to the wonderful world of container controls
    they are a tad odd in that while you create a new instance of your specific container control when iteratiing the controls you have to look for EmbeddedWindowControl instances

    var newCC(6) As ContainerControl1
    newCC(index) = new ContainerControl1
    var i as integer
    
    for i =(controlcount-1) downto 0 
      if control(i) isA EmbeddedWindowControl then 
        break
        newCC(i).hide
      end
    next i
    newCC(index).EmbedWithin(Self, 50, 100)
    
  3. Clifford C

    Jun 27 Port Angeles, Washington

    @Norman P welcome to the wonderful world of container controls
    they are a tad odd in that while you create a new instance of your specific container control when iteratiing the controls you have to look for EmbeddedWindowControl instances
    var newCC(6) As ContainerControl1 newCC(index) = new ContainerControl1 var i as integer for i =(controlcount-1) downto 0 if control(i) isA EmbeddedWindowControl then break newCC(i).hide end next i newCC(index).EmbedWithin(Self, 50, 100)

    Of course. Tough to be new green.

    EmbeddedWindowControl did the trick but another problem came up. The second time you call this method an out of bounds. exception error occurs at newCC(i).hide. Maybe this will be oblivious to you.

  4. Markus R

    Jun 27 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 6 days ago

    your controlcount is bigger than your array.
    you use i wrong.
    maybe it is more control(i).hide

  5. Clifford C

    Jun 27 Port Angeles, Washington
    Edited 6 days ago

    @Markus R your controlcount is bigger than your array.
    you use i wrong.

    I increased the array newCC(6) to newCC(100) but it still errored

  6. Norman P

    Jun 27 Testers, Xojo Pro outside admiring the sunshine,...

    @CliffordCoulter Of course. Tough to be new green.

    EmbeddedWindowControl did the trick but another problem came up. The second time you call this method an out of bounds. exception error occurs at newCC(i).hide. Maybe this will be oblivious to you.

    tell me whats the intent of the newCC array ?
    if its to track all instans then it should be a property of the window
    and your code might then be

    var newInstance As ContainerControl1
    newInstance = new ContainerControl1
    
    for i as integer = (controlcount-1) downto 0 
      if control(i) isA EmbeddedWindowControl then 
        break
        control(i).hide
      end
    next i
    
    newinstance.EmbedWithin(Self, 50, 100)
    newCC.Append newinstance
  7. Clifford C

    Jun 27 Port Angeles, Washington
    Edited 6 days ago

    @Norman P tell me whats the intent of the newCC array ?
    if its to track all instans then it should be a property of the window
    and your code might then be

    var newInstance As ContainerControl1 newInstance = new ContainerControl1 for i as integer = (controlcount-1) downto 0 if control(i) isA EmbeddedWindowControl then break control(i).hide end next i newinstance.EmbedWithin(Self, 50, 100) newCC.Append newinstance

    I wanted to see if it was feasible to create a window and populated it with a container control for each day of the week. These would be assigned to a control array property in the holding window. The data for that day would be stored in the day-specific container control. I'm trying to reason out how it could be put together. And you are correct newCC(6) was to track the array.

  8. Norman P

    Jun 27 Testers, Xojo Pro outside admiring the sunshine,...

    OK
    So newCC should be a property of the window
    That way the array will stick around until the window is closed

    And then is this code is to create the one if it didnt exist before ?

  9. Clifford C

    Jun 27 Port Angeles, Washington
    Edited 6 days ago

    I'm not sure how (newCC.Append newinstance ) works. Is it an array property that can keep tack of each of the 0-6 days of the week?

    Actually I was thinking of creating all of them when opening the window, one for each day and hiding them when not needed. Maybe that's not the best way to do it. I'm muddling through this. NewCC(index).EmbedWithin(Self, 50, 100) does created another but I will replace it with a show command when I figure out what that is.

    I'm thinking maybe newCC.Append newinstance appends or grows an array. is that true?

  10. Clifford C

    Jun 27 Port Angeles, Washington

    In your example of the parent window owning the preference, how do you reference the days of the week to show and hide the days of the week if they are not indexed in some way? They would also need to be indexed in the preference array in the main window so they could be stored and loaded back in when the window opens again. ?????

  11. Markus R

    Jun 27 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 6 days ago

    i would place your 7 cc in the window.
    at window open put them in your property which is an array. there you can also set the position at the window if needed.
    if you will hide them all use for each with your property / array.
    if you will show one use date day of week as index for your property / array.

  12. Tim S

    Jun 28 Testers Canterbury, UK

    Where do you initialise controlcount?

  13. 4 days ago

    Clifford C

    Jun 29 Port Angeles, Washington

    @Markus R i would place your 7 cc in the window.
    at window open put them in your property which is an array. there you can also set the position at the window if needed.
    if you will hide them all use for each with your property / array.
    if you will show one use date day of week as index for your property / array.

    When it was done Markus I did not need a reference to keep track. It was amazingly simple to code overall, well with a little help learning how to pass the array(,). I though multidimensional arrays needed to be in a wrapper class to be passed. Not so.

or Sign Up to reply!