嗨,我正在寻找任何想法来做这样的事情:
一些文字------------------------------------------------ ---
这个“------”我必须让按钮点击到行尾。
我的想法是用虚线领导在制表位上制作它,但这会产生问题,因为当我尝试在此之后在文本中使用 ^t 时,它也会产生破折号。不能仅通过键入破折号来完成,因为第二个按钮是从整个文档中清除该破折号。
这是我制作的代码,但就像我说的那样不好,因为 ^t 在文档的任何其他位置都很糟糕
public void DashingSingleLane()
{
Word.Range rng = Globals.ThisAddIn.Application.Selection.Range;
if (rng.Start == rng.End)
{
float pageWidth = classDocument.PageSetup.PageWidth - classDocument.PageSetup.LeftMargin - classDocument.PageSetup.RightMargin;
foreach (Word.Paragraph singleParagraph in rng.Paragraphs)
{
if ((singleParagraph.Range.Text != "\r") && (singleParagraph.Range.Text.IndexOf("\t") == -1))
{
singleParagraph.TabStops.Add(pageWidth, Word.WdTabAlignment.wdAlignTabRight, Word.WdTabLeader.wdTabLeaderDashes);
Globals.ThisAddIn.Application.Selection.EndKey(Microsoft.Office.Interop.Word.WdUnits.wdLine);
Globals.ThisAddIn.Application.Selection.TypeText("\t");
}
}
}
}
我发现为了让它变得更好,我还需要将 Tabstop 与左对齐恰好放在句末。类似的东西
singleParagraph.TabStops.AddPosition_in_Point, Word.WdTabAlignment.wdAlignTabLeft, Word.WdTabLeader.wdTabLeaderDashes);
但我不知道如何准确定位
我从 2 天开始就在考虑这个问题,但我没有任何好主意。我希望有人会有一些好的想法。