使用 C# 我成功打开了一个 Word 文档并向其中写入文本。现在我想使用 C# 代码将文本框插入到 Word 文档中,并且我使用在互联网其他地方找到的代码成功了。这是代码:-
Microsoft.Office.Interop.Word.Shape textbox = oDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 70, 30); //MsoTextOrientation.msoTextOrientationVertical
textbox.TextFrame.TextRange.Text = "Date";
效果很好。但我的问题是,我想用 c# 代码隐藏文本框的默认边框。我尝试寻找它,但没有找到。
有人可以帮助我吗?提前致谢 印度乌尼克里希南
最佳答案
Microsoft.Office.Interop.Word.Shape textbox = oDoc.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, 70, 30);`
textbox.TextFrame.TextRange.Text = dateTimePicker1.Value.toShortDateString();`//this will insert a ms word textbox on ms word document.
textbox.Line.Visible = MsoTriState.msoFalse;` // this will hide the border or line of textbox.
textbox.TextFrame.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;` //this will align the text within the textbox to rthe right side of the textbox.
//这个oDoc中就是添加的文档。
Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document oDoc = new Microsoft.Office.Interop.Word.Document();
//我在Windows XP和Windows 7操作系统的不同计算机上用Visual C# Express 2010和Word 2007和2010进行了尝试。
关于c# - 如何隐藏word文本框边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20018329/