使用 Interop.Access 在 Access 中获取页眉和页脚的文本 [英] Get the text of Headers and Footers in Access using Interop.Access
本文介绍了使用 Interop.Access 在 Access 中获取页眉和页脚的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using AccessApi = Microsoft.Office.Interop.Access;
foreach (AccessApi.Control control in ap.Forms[formName].Section[AccessApi.AcSection.acHeader].Controls)
{
logger.Info(control.Name);
}
但是通过这些我得到了控件的名称(AutoLogo 或 AutoTitle).例如,我想获取标题的文本.我该怎么做?
But with these I get the Name (AutoLogo or AutoTitle) of the control. I want to get the text of the Title for example. How do I do this?
推荐答案
最终我无法访问 control.Value
和 control.Caption
的方式是因为它不是't 一个 LabelClass 属性,如@Unhandled Exception 所说.所以我这样做了:
Eventually the way I could not access control.Value
and control.Caption
was because it wasn't a LabelClass property as @Unhandled Exception said. So I did this:
foreach (AccessApi.Control control in ap.Forms[formName].Section[AccessApi.AcSection.acHeader].Controls)
{
Type t = control.GetType();
if (t.Equals(typeof(AccessApi.LabelClass)))
{
AccessApi.Label label = (AccessApi.Label)control;
logger.Info(label.Caption);
}
}
这篇关于使用 Interop.Access 在 Access 中获取页眉和页脚的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文