Results 1 to 10 of 10

Thread: [RESOLVED] re-order control array??

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Resolved [RESOLVED] re-order control array??

    hey , guys ....

    another control array problem

    I have control array of pictures
    let's say

    pic(0)
    pic(1)
    pic(2)
    pic(3)
    pic(4)
    pic(5)
    pic(6)
    user can delete any of those in run-time ... so if he deletes pic(3) then we have :

    pic(0)
    pic(1)
    pic(2)
    pic(4)
    pic(5)
    pic(6)

    the problem is that I want these array to re-order itself to become

    pic(0)
    pic(1)
    pic(2)
    pic(3)
    pic(4)
    pic(5)
    Am I make sense??? and if I do , Is that possible to make???

    thanks in advance
    Last edited by karim_fone; Apr 6th, 2009 at 04:27 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: re-order control array??

    with other controls it easier than a picturebox or image control
    you would need add a control to replace the deleted one, then loop through all the controls from the new one, in this case 3 to 5 and copy the all the required properties form the one above probably have to copy top,left,height,width,picture,image,font (all properties), autoredraw, maybe someothers, any that are default from creation should not need changing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Re: re-order control array??

    so , isn't won't work with picturebox ??

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: re-order control array??

    yes it work for picturebox, just more properties to copy, especially if pictureboxes have different sized pictures or images
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Re: re-order control array??

    thanks for helping , I will try it
    Last edited by karim_fone; Apr 5th, 2009 at 06:52 AM.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: re-order control array??

    Is there a particular reason that you want the numbers to not have any gaps?

    If it is just so that you can loop thru them, it doesn't matter about the gaps - just use a For Each loop, eg:
    Code:
    Dim objPic as PictureBox
      For Each objPic In pic
        objPic.Cls
        objPic.Print "hello!"
      Next objPic

  7. #7

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Re: re-order control array??

    ok , here is the thing , I use vsflexgrid for layers , every layer has it's properties , and within : the color
    like picture below
    ok , I make control array on picturebox , so when user press new layer button , new layer will be added with editable colorful picturebox , the thing is when user delete current layer ... there will be one more picturebox than the already rows I have

    I hope I was clear enough
    Attached Images Attached Images  

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: re-order control array??

    In that case it makes sense.

    One minor thing, rather than removing and re-adding, I would recommend that you remove the last picturebox instead, then update the properties as apt for the ones down to the 'removed' one.

  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Re: re-order control array??

    that's good call ... I should give it shot , thanks ..

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2009
    Posts
    46

    Re: [RESOLVED] re-order control array??

    thanks for help , guys , and si_the_geek , it worked that way , thanks for helping

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width