We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change position of WTextBox

Thread ID:

Created:

Updated:

Platform:

Replies:

149304 Nov 21,2019 09:06 AM UTC Dec 2,2019 11:34 AM UTC WinForms 7
loading
Tags: DocIO
AtliDev
Asked On November 21, 2019 09:06 AM UTC

hi,
I have a document with a WTextBox in the HeadersFooters , when i change the PageSize and the Orientation of the document the WTextBox change the position.
So i tried to reposition the WTextBox by code but it doesn't work.
How can i do this ? Thanks 
The code that i use:
     
     For Each _section As WSection In a.Sections
            _section.PageSetup.PageSize = PageSize.A3
            _section.PageSetup.Orientation = PageOrientation.Landscape
            For Each _element As Entity In _section.HeadersFooters.EvenHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.FirstPageHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.Header.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.OddHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
        Next


The function :

Private Sub ShapeTestChangePosition(ByVal _element As WParagraph)
        Dim para As WParagraph = _element
        For Each _sselement As Entity In para.ChildEntities
            If TypeOf _sselement Is WTextBox Then
                Dim _textbox As WTextBox = _sselement
                     _textbox.TextBoxFormat.HorizontalPosition = HorizontalPosition.Right
                     _textbox.TextBoxFormat.VerticalPosition = VerticalPosition.Bottom
                     _textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin
                     _textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page
            End If
        Next




u will found attached the document.

Thanks for help



Attachment: exemple1_243674c2.rar

Suriya Balamurugan [Syncfusion]
Replied On November 22, 2019 11:00 AM UTC

Hi AtliDev,

Thank you for contacting Syncfusion support.

On analysing further, we have found that the input Word document textbox have horizontal position with respect to column and vertical position with respect to page. In Microsoft Word, while changing page size and orientation, to preserve the textbox in right - bottom corner of the page means sets the textbox position with respect to right - bottom margin which is not supported by Microsoft Word in DOC format. So we positioned the textbox to right – bottom corner of the page as per your requirement by calculating the page size.

We have prepared a sample application to change the position of the textbox as per your requirement and it can be downloaded from the below link:

https://www.syncfusion.com/downloads/support/forum/149304/ze/VB_Windows1895570612

Note: Please find the template Word document in “Data” folder of above sample application.

In the above sample, we have done the following things:
  1. Loads the input Word document.
  2. Changes the page size and orientation of the Word document.
  3. Gets the value of page size before and after changing the page size and orientation.
  4. Iterates to the corresponding textbox.
  5. Gets the position of the textbox.
  6. Calculates the new position of the textbox from the page size.
  7. Sets the new position values to the textbox.
  8. Saves the Word document.

Please let us know if you have any other questions.

Regards,
Suriya Balamurugan.


AtliDev
Replied On November 22, 2019 12:58 PM UTC

Hi,

Thanks for helping , 
i will try the proposed step, but i didn't found the code in the given sample.

thanks.

Suganya Rathinam [Syncfusion]
Replied On November 25, 2019 11:39 AM UTC

Hi AtliDev,

Thanks for the update.

In the provided sample the method btnCreate_Click() in the file Form1.Designer.vb will have the code to position the textbox in the Word document. Please try running the provided sample and let us know whether it helps.

Regards,
Suganya R


AtliDev
Replied On November 28, 2019 01:53 PM UTC

hi,
thanks for help. the positionnement of textbox is work now.
but the problem is came from linktoprevious , if my section has headersfooters link to previous = true , nothing is change.

i found also a problem when i do my test : 
( if my second section linktoprevious = false , and we force changing a other time linktoprevious to false , i found a header or footer with double contents )

thanks for help
AtliDev

Suganya Rathinam [Syncfusion]
Replied On November 29, 2019 08:41 AM UTC

Hi AtliDev,

Thank you for the update.

We tried to reproduce the mentioned Header/Footer difference with the provided details. But the result is preserved as expected. Please find the sample we tried from the following link.

https://www.syncfusion.com/downloads/support/forum/149304/ze/VB_Windows1895570612-1549194220

Kindly modify the sample with the input document used, and the code snippets tried at your end and share the same. We will analyze further on that and update you the details.

Regards,
Suganya R


AtliDev
Replied On November 29, 2019 09:30 AM UTC

hi, 

thanks for update,

you need to have the second section in the document with link to previous false ( i attach the document for test )
and if by code you force the section to change linktoprevious = false you will see the double header and footer.

thanks.


Attachment: Test_5c287b54.rar

Suganya Rathinam [Syncfusion]
Replied On December 2, 2019 11:34 AM UTC

Hi AtliDev,

Thank you for the update.

We can reproduce the mentioned issue in the header/footer when the LinkToPrevious is set to false. We confirmed it as defect and the fix for this issue will be included in our 2019 Volume 4 release which is expected to be available in the mid of December 2019.

The status of the issue can be tracked with the following link:
https://www.syncfusion.com/feedback/10520/header-footer-gets-duplicated-when-linktoprevious-is-diabled


Regards,
Suganya R


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon