Ok,
I have been playing around with this code and another I found online.
Currently this is not working and I was hoping someone could maybe point me in the right direction.
Below is my code, with some annotation as to what I think is going on (my very limited knowledge).
Public Sub MoveElements()
Dim activeview As IActiveView
Dim pageLayout As IPageLayout = New PageLayoutClass()
Dim name As String
Dim pmxdoc As IMxDocument
pmxdoc = My.ArcMap.Document
'Make pagelayout the active view
pmxdoc.ActiveView = pmxdoc.PageLayout
activeview = pmxdoc.ActiveView
name = "1"
If TypeOf activeview Is IPageLayout Then
pageLayout = TryCast(activeview, IPageLayout)
Dim graphicsContainer As IGraphicsContainer = TryCast(pageLayout, IGraphicsContainer)
graphicsContainer.Reset()
Dim transform2D As ITransform2D
Dim elem As IElement
'''''''''''''''
elem = GetElementInContainer(elem, name) 'So the way I see it here: I am setting up which of the graphics will be selected based on the "name" taken from the function
'While Not elem Is Nothing
transform2D = TryCast(elem, ITransform2D)
transform2D.Move(10, 0)
'elem = graphicsContainer.Next()
'End While
Else
MessageBox.Show("This tool only works in pagelayout view.")
End If
'Refresh only the page layout's graphics.
activeview.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
End Sub
Private Function GetElementInContainer(ByVal container As IGraphicsContainer, ByVal name As String) As IElement
Dim graphicsContainer As IGraphicsContainer
'graphicsContainer = TryCast(pagelayout, IGraphicsContainer)
'Loop through all the elements and move each one inch.
' graphicsContainer.Reset()
'container.Reset() ### I kept having a crash here, so I played around with the graphics container.
'####### It doesnt get passed here #####
Dim elem As IElement
'Dim elem As IGraphicElement = container.Next
elem = graphicsContainer.Next
While elem IsNot Nothing
Dim elemProps As IElementProperties = DirectCast(elem, IElementProperties)
If String.Compare(elemProps.Name, name, True) = 0 Then
Return elem
End If
elem = graphicsContainer.Next
End While
Return Nothing
End Function
Any ideas, recommendations are welcome!!
Thanks
K