c# - 如何隐藏word文本框边框?

标签 c# ms-office office-interop

使用 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/

相关文章:

c# - 条形码到产品名称转换器

VBA : Disabling Listbox while macro is running

c# - 在标题中的 word 2003 自动化中使用拖放的奇怪行为

excel - F# ExcelUsedRange 没有属性或方法

c# - 如何使用 Microsoft.Office.Interop.Word.Document.PrintOut() 将 docx 打印到特定打印机

c# - 如何在不创建新列表的情况下重命名列表中的值?

c# - Wpf 绑定(bind)列列表

c# - HttpClient.PostAsync 以退出代码 0 终止程序

vba - 使用宏将 Ms word 中的所有形状转换为图像

c# - 如何使用 Office Interop 在 PowerPoint 的自定义任务 Pane 中创建形状并将该形状添加到类别中