Advertisement

07.17.2008 at 11:02AM PDT, ID: 23574268 | Points: 500
[x]
Attachment Details

Allowing the user to align controls at runtime

Asked by Dodsworth in Microsoft Visual Basic.Net

Tags: vb.net 2008 express

Imagine a form with lots of randomly positioned colored labels on.
The arrow keys allow the user to move the 'selected' label in a given direction such that each press of a button 'snaps' the selected label to the vertices of the next nearest label.

I started this by building a 2 lists of the label vertices....

lstX.Clear()
        lstY.Clear()
        For Each Shape In Main.Shapes
            If Not lstX.Contains(Shape.Location.X) Then
                lstX.Add(Shape.Location.X)
            End If
            If Not lstX.Contains(Shape.Location.X + Shape.Size.Width) Then
                lstX.Add(Shape.Location.X + Shape.Size.Width)
            End If
            If Not lstY.Contains(Shape.Location.Y) Then
                lstY.Add(Shape.Location.Y)
            End If
            If Not lstY.Contains(Shape.Location.Y + Shape.Size.Height) Then
                lstY.Add(Shape.Location.Y + Shape.Size.Height)
            End If
        Next
        lstX.Sort()
        lstY.Sort()

which is refreshed every time a label moves.

On key press i fetch the postion of the currentshape in the list and return the next vertex

                             Case Keys.Up
                                     currentShape.Location = New Point(currentShape.Location.X, lstY.ElementAt(lstY.FindIndex(Function(iFinder As Integer) iFinder = currentShape.Location.Y) - 1))
                            Case Keys.Down
                                     currentShape.Location = New Point(currentShape.Location.X, lstY.ElementAt(lstY.FindIndex(Function(iFinder As Integer) iFinder = currentShape.Location.Y) + 1))
                            Case Keys.Left
                                     currentShape.Location = New Point(lstX.ElementAt(lstX.FindIndex(Function(iFinder As Integer) iFinder = currentShape.Location.X) - 1), currentShape.Location.Y)
                            Case Keys.Right
                                     currentShape.Location = New Point(lstX.ElementAt(lstX.FindIndex(Function(iFinder As Integer) iFinder = currentShape.Location.X + currentShape.Width) + 1), currentShape.Location.Y)

Up and Left work as they should but Down and Right do not.  I need to factor in the height/width of the selected shape and prevent it from snapping to it's own bottom/right vertex.

Could be going about this completely the wrong way !

Ideas please ?Start Free Trial
 
Loading Advertisement...
 
[+][-]07.18.2008 at 02:46AM PDT, ID: 22034109

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 05:18AM PDT, ID: 22034873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 07:27AM PDT, ID: 22036125

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 09:05AM PDT, ID: 22060841

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 09:19AM PDT, ID: 22060978

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 10:12AM PDT, ID: 22061469

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 06:47AM PDT, ID: 22069234

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 07:36AM PDT, ID: 22069723

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 09:25AM PDT, ID: 22070932

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 09:26AM PDT, ID: 22070945

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 09:55AM PDT, ID: 22071247

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 01:18PM PDT, ID: 22073409

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 01:18PM PDT, ID: 22073412

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 05:32AM PDT, ID: 22078339

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 06:02AM PDT, ID: 22078600

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 06:13AM PDT, ID: 22078709

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 06:25AM PDT, ID: 22078813

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 08:34AM PDT, ID: 22080305

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 09:47AM PDT, ID: 22081130

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 10:31AM PDT, ID: 22081524

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 07:41AM PDT, ID: 22089000

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 07:57AM PDT, ID: 22089144

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 09:13AM PDT, ID: 22089917

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 09:29AM PDT, ID: 22090059

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 08:42AM PDT, ID: 22130754

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 09:44AM PDT, ID: 22131349

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.01.2008 at 06:41AM PDT, ID: 22138097

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.04.2008 at 04:11AM PDT, ID: 22151432

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.04.2008 at 05:30AM PDT, ID: 22151827

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.25.2008 at 07:32PM PDT, ID: 22311141

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628