以下是在header中插入TextField和获取TextField的代码片段:
- private void getToolStripMenuItem_Click(object sender, EventArgs e)
- {
- // 获取当前所在的 Section
- TXTextControl.Section currentSection = textControl1.Sections.GetItem();
- // 当前页眉
- TXTextControl.HeaderFooter currentHeader =
- currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header);
- // 检查是否已经添加页眉
- if (currentHeader != null)
- {
- MessageBox.Show(currentHeader.TextFields.Count.ToString());
- }
-
- }
- private void insertToolStripMenuItem_Click(object sender, EventArgs e)
- {
- // 获取当前所在的 Section
- TXTextControl.Section currentSection = textControl1.Sections.GetItem();
- // 当前页眉
- TXTextControl.HeaderFooter currentHeader =
- currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header);
- // 检查是否已经添加页眉
- if (currentHeader == null)
- {
- // 如果没有添加页面,在此添加
- currentSection.HeadersAndFooters.Add(TXTextControl.HeaderFooterType.Header);
- currentHeader = currentSection.HeadersAndFooters.GetItem(TXTextControl.HeaderFooterType.Header);
- }
- // 添加文本域
- currentHeader.TextFields.Add(new TXTextControl.TextField("测试"));
- }
复制代码
10074_TextField.zip
(12.06 KB, 下载次数: 131)
|