本文整理汇总了C#中Epi.Page.CreateField方法的典型用法代码示例。如果您正苦于以下问题:C# Page.CreateField方法的具体用法?C# Page.CreateField怎么用?C# Page.CreateField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epi.Page
的用法示例。
在下文中一共展示了Page.CreateField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyField
/// <summary>
/// Converts a field
/// </summary>
/// <param name="fieldRow">A field record from the legacy database</param>
/// <param name="page">A page object</param>
/// <param name="tableName">Name of the view table in EI 3.x</param>
private void CopyField(DataRow fieldRow, Page page, string tableName)
{
RenderableField field = null;
try
{
bool FieldHasBeforeCheckCode = false;
bool FieldHasAfterCheckCode = false;
bool FieldHasClickCheckCode = false;
string ckBefore = String.Empty;
string ckAfter = String.Empty;
MetaFieldType fieldType = Epi.Epi2000.MetadataDbProvider.InferFieldType(fieldRow);
field = (RenderableField)page.CreateField(fieldType);
if (field is GridField)
{
// Grids not supported in initial 7.0.7 release
Logger.Log(DateTime.Now + ": " + string.Format(SharedStrings.IMPORT_WARNING_GRID_NOT_SUPPORTED, field.Name));
return;
}
// Field Name
string fieldName = fieldRow[ColumnNames.NAME].ToString();
// KKM4 - Commented out to test the requirement of Reserved words.
//if (Epi.Data.Services.AppData.Instance.IsReservedWord(fieldName))
//{
// throw new ReservedWordException(fieldName);
//}
//else
//{
// field.Name = fieldName;
//}
field.Name = fieldName;
// ControlFont
if (!string.IsNullOrEmpty(fieldRow["Ffont"].ToString()))
{
if (!string.IsNullOrEmpty(fieldRow["Ffontsize"].ToString()))
{
if (float.Parse(fieldRow["Ffontsize"].ToString()) > 0)
{
field.ControlFont = new System.Drawing.Font(fieldRow["Ffont"].ToString(), float.Parse(fieldRow["Ffontsize"].ToString()));
}
}
}
// ControlHeightPercentage
if (fieldRow["Fsize"] != DBNull.Value)
{
field.ControlHeightPercentage = (double)fieldRow["Fsize"];
}
// ControlLeftPositionPercentage
if (fieldRow["Flocx"] != DBNull.Value)
{
field.ControlLeftPositionPercentage = ((double)fieldRow["Flocx"]) / 100;
}
// ControlTopPositionPercentage
if (fieldRow["Flocy"] != DBNull.Value)
{
field.ControlTopPositionPercentage = ((double)fieldRow["Flocy"]) / 100;
}
// ControlWidthPercentage
if (fieldRow["Dsize"] != DBNull.Value)
{
field.ControlWidthPercentage = (double)fieldRow["Dsize"];
}
// HasTabStop
field.HasTabStop = true;
// Prompt
if (fieldRow["Prompt"] != DBNull.Value)
{
field.PromptText = fieldRow["Prompt"].ToString();
}
// TabIndex
if (fieldRow["Taborder"] != DBNull.Value)
{
field.TabIndex = int.Parse(fieldRow["Taborder"].ToString());
}
// Check Code
if (fieldRow[ColumnNames.CHECK_CODE] != DBNull.Value)
{
string checkCode = fieldRow[ColumnNames.CHECK_CODE].ToString();
Epi.Epi2000.MetadataDbProvider.SplitCheckCode(checkCode, ref ckBefore, ref ckAfter);
if (field is IFieldWithCheckCodeAfter)
{
//.........这里部分代码省略.........
示例2: ReadDataSource
public void ReadDataSource(DataTable table)
{
if (table != null)
{
IMemoryRegion region = MemoryRegion;
FieldCollectionMaster dataFields = new FieldCollectionMaster();
Project tempProject = new Project();
View tempView = new View(tempProject);
Page tempPage = new Page(tempView);
DataInfo.PrimaryTable = table;
List<IField> listOfFields = new List<IField>();
foreach (DataColumn column in table.Columns)
{
IField field = (IField)tempPage.CreateField(MetaFieldType.Text);
field.Name = column.ColumnName;
RenderableField tempField = (RenderableField)field;
tempField.PromptText = column.ColumnName;
tempField.SourceTable = table.TableName;
listOfFields.Add(tempField);
}
foreach (IField field in listOfFields)
{
region.DefineVariable((IDataField)field);
}
if (CurrentRead != null && CurrentRead.IsEpi7ProjectRead && CurrentProject != null && CurrentProject.Views.Exists(CurrentRead.Identifier))
{
View view = CurrentProject.Views[CurrentRead.Identifier];
foreach (IField field in view.Fields)
{
if (field is GroupField)
{
IVariable v = new DataSourceVariable(field.Name, DataType.Unknown);
region.DefineVariable(v);
}
}
}
foreach (KeyValuePair<string, List<string>> kvp in GroupVariableList)
{
IVariable v = new DataSourceVariable(kvp.Key, DataType.Unknown);
region.DefineVariable(v);
}
}
}
示例3: Convert
/// <summary>
/// Start the conversion process
/// </summary>
public void Convert()
{
if (SetStatus != null)
{
SetStatus("Creating form...");
}
project.CreateView(formName, false);
View destinationView = project.Views[formName];
List<int> pages = new List<int>();
foreach(ColumnConversionInfo cci in columnMapping)
{
if(!pages.Contains(cci.PageNumber))
{
pages.Add(cci.PageNumber);
}
}
pages.Sort();
if (SetStatus != null)
{
SetStatus("Creating pages...");
}
for(int i = 0; i < pages.Count; i++)
{
Page page = new Page(destinationView);
page.Name = "Page " + (i + 1).ToString();
page.Position = i;
destinationView.Pages.Add(page);
destinationView.SaveToDb();
page.SaveToDb();
}
if (SetStatus != null)
{
SetStatus("Creating fields...");
}
foreach(ColumnConversionInfo cci in columnMapping)
{
if (SetStatus != null)
{
SetStatus("Creating field " + cci.DestinationColumnName + "...");
}
Page page = destinationView.GetPageByPosition(cci.PageNumber - 1);
Field field = null;
switch(cci.FieldType)
{
case MetaFieldType.Checkbox:
case MetaFieldType.YesNo:
case MetaFieldType.Text:
case MetaFieldType.Multiline:
case MetaFieldType.Date:
case MetaFieldType.DateTime:
case MetaFieldType.Time:
case MetaFieldType.LegalValues:
case MetaFieldType.Number:
field = page.CreateField(cci.FieldType);
break;
default:
throw new ApplicationException("Invalid field type");
//break;
}
SetFieldProperties(field, cci);
page.AddNewField((RenderableField)field);
}
destinationView.SaveToDb();
}