Moving a textbox

I have a textbox shape on an Excel chart. I get a handle to it in code and set the text propery. Doing so seems to move the textbox slightly up and to the right on the graph. I tried moving it back in code using Left, Top, and Upper/LowerDelta with no success. Is there a way to move the textbox down and to the left about 20 pixels both ways? Here is my code.

txt = CType(GetShape(cht, "TextBox 7"), Aspose.Cells.TextBox)

txt.Text = "Cutoff: " & CStr(m_typTest(lngThisTest).Cutoff)

txt.Placement = PlacementType.FreeFloating

txt.Left = 15

txt.Top = 580

Hi,

I think you may get the textbox object using Chart.Shapes attributes. I have tested it using a template file which has a chart in it. On the chart there is a textbox placed on it. I get the textbox object and change its position using TextBox.TopInShape and TextBox.LeftInShape properties, there are quite a few more. Check the following code.

e.g..,

'Create a new Workbook.
Dim workbook As New Workbook()
'
Open the existing file.
workbook.Open("f:\test\mychartbook.xls")
'Get the designer chart in the second sheet.
Dim sheet As Worksheet = workbook.Worksheets(1)
Dim chart As Chart = sheet.Charts(0)
'
Get the textbox shape on the chart.
Dim textbox0 As Aspose.Cells.TextBox = CType(chart.Shapes(0), Aspose.Cells.TextBox)
'Change the value of the textbox
textbox0.Text = "a value"
'
change the position on the chart.
textbox0.LeftInShape = 3900
textbox0.TopInShape = 900

And for reference how to add shapes on the charts, please check: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/inserting-controls-into-charts.html

Thank you.

LeftInShape seems to move the text box to the right if I increase the value. TopInShape seems to just increase the height of the text box. The top line of the text box goes up the worksheet if I decrease the value of this property but the bottom line says where it is. I need the textbox to actually move down the worksheet.

Hi,

Well, there seems to have some sort of issue with TopInShape attribute as it does not work as expected. We will look into it soon.

Thank you.

Hi,

Please try the attached fix, we have fixed the issue.

And, if you want to move a shape to the chart right-bottom corner, please consult the following codes:
Aspose.Cells.Shape shape = workbook.Worksheets[0].Charts[0].Shapes[0];
shape.LeftInShape = 4000 - shape.WidthInShape;
shape.TopInShape = 4000 - shape.HeightInShape;
Thank you.

The issues you have found earlier (filed as 7336) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Laurence.