Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Is it possible to move a Control, for example a checkbox, in word?

There is no method provided for the controls so I tried to remove and then add it again at the new location. My problem with this "solution" is, that the control gets completly white and it's events doesn't work anymore.

Many thanks in advance for your help
Posted
Updated 28-Mar-14 13:39pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Mar-14 18:00pm    
The question makes no sense, because if you want to move something, this "something" should exist. There are no System.Windows.Forms controls in Microsoft Office Word.
It is possible that you mean something which actually makes sense, but you certainly did not express it.
And, by the way, why having any controls in Word? Only because it is possible? :-)
—SA
Daniel Morgenbesser 28-Mar-14 18:27pm    
Oh it makes sense, ... more or less.
This is my final year project and I have different Winforms in word. I get the location through a leftclick on a richtextbox, which is over the whole page.
At the moment I'm able to create the controls, save them into a database and load them later so they do exist. ;)
Now I need to move the controls, because the user could place them between two lines and the word text would be behind the control.

1 solution

I take it this is a Word extension?? If not, you've using terminology in the wrong ways and have gotten some concepts wrong.

Form each every visual control, you can move simply by setting a new Location value, which takes a Point object I believe, or, individually setting the Left and Top properties of the control in question.
 
Share this answer
 
Comments
Daniel Morgenbesser 28-Mar-14 19:27pm    
That doesn't work. I must add and remove the control with the exact location to word, after that I can't add it again because everything gets white. May you ask know why I'm not creating a new control with the same properties, but then would'nt my move event work anymore, because I also need to click on the control.
And it is an add-in.

btw thanks for your help^^
Dave Kreskowiak 29-Mar-14 1:30am    
You're telling me you can't set the Location, Top or Left properties. Why?
Daniel Morgenbesser 29-Mar-14 8:01am    
I can set the location but I need to add the control with the new location to the word controls before word shows anything ...

This is the method to add controls:
thisdocument.Controls.AddControl(control,left,top,width,height,name);
Dave Kreskowiak 29-Mar-14 9:57am    
Ah. Unfortunately, I can't test this because I don't have VS installed on the machine I have access to right now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900