We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,849 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Problem with Panel ordering.

Hello my fellow DanniWebbers, it is me againg. I have yet another question for you guys and gals.


I have a parent panel with child panels that contain images. I am looping through the panels to save the images in the order the panels appear in the parent panel.


I am using:

for p as Panel in ImagePanel.Controls
  scannedImages(j) = p.BackGroundImage
  j += 1
next

I can also re-arrange the panels via mouse. The problem is that when they are rearranged, they do not retain their order when saved.. They simply are saved in the order they were added to the parent panel.

So my question is, does the for loop use the index set when adding the panel? If so, how can I manipulate the index in runtime while arranging the panels via mouse.

2
Contributors
4
Replies
1 Month
Discussion Span
1 Year Ago
Last Updated
6
Views
Question
Answered
Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 142
Skill Endorsements: 8

One suggestion is to declare an array of references to panel and assign the panels to the array in the order you want to reference them.

Private panels(2) as Panel

panels(0) = myPanel1
panels(1) = myPanel2
panels(2) = myPanel3
Reverend Jim
Carpe per diem
Moderator
3,595 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32

That is what I have scannedimages for, but for some reason it does not want to keep the order of the panels post rearrange. I would like to have the ability to move the panels and when the user presses "Save", the panels are then saved in their current order. The problem is, they are saved in the order they were scanned in. :(

Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 142
Skill Endorsements: 8

If I understand correctly, you could save the positions of the panels in My.Settings then restore those positions when you reopen the app.

Reverend Jim
Carpe per diem
Moderator
3,595 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
Question Answered as of 1 Year Ago by Reverend Jim

Sorry for long reply, and not marking question solved.....

Answer was to loop through the panels and do a buble sort.

Sudo

is next.y position < this.y Position
Yes: this.index = next.index, next.index = this.index

ect...

That way it resorts the index of the panels (Which is what is used when looping through controls.

Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 142
Skill Endorsements: 8

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0767 seconds using 2.7MB