你在加载文档之后对文档中的FormDropDown进行重新设置,将数据库中取出来的数据设置给FormDropDown控件,下面是一个简单的代码片段:- private void loadToolStripMenuItem_Click(object sender, EventArgs e)
- {
- TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings();
- ls.ApplicationFieldFormat = TXTextControl.ApplicationFieldFormat.MSWord;
- ls.ApplicationFieldTypeNames = new string[] { "FORMDROPDOWN" };
- textControl1.Load(TXTextControl.StreamType.MSWord | TXTextControl.StreamType.WordprocessingML, ls);
- DataTable dt = new DataTable();
- dt.Columns.Add("ID");
- dt.Columns.Add("Family");
- dt.Rows.Add(1, "汉族");
- dt.Rows.Add(2, "回族");
- dt.Rows.Add(3, "布衣族");
- foreach (TXTextControl.ApplicationField field in textControl1.ApplicationFields)
- {
- ArrayList ParameterList = new ArrayList();
- if (!String.IsNullOrEmpty(field.Name) && field.Name.Equals("fieldFamily"))
- {
- //加载ListEntries以外的属性设置
- foreach (var item in field.Parameters)
- {
- if (!item.Contains("w:listEntry w:val"))
- {
- ParameterList.Add(item);
- }
- }
- //加载listEntry的属性
- foreach (DataRow row in dt.Rows)
- {
- ParameterList.Add(String.Format("w:listEntry w:val=\"{0}\"", row["Family"]));
- }
- field.Parameters = ParameterList.ToArray(System.Type.GetType("System.String")) as string[];
- }
- }
- }
复制代码 |