⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codesfielddefinition.cs

📁 EpiInfo 开源的导航系统远程序,不知道在哪里下的了,分享一下,有兴趣的
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Epi.Fields;


namespace Epi.Windows.MakeView.Dialogs.FieldDefinitionDialogs
{
    /// <summary>
    /// Field definition dialog for codes fields
    /// </summary>
    public partial class CodesFieldDefinition : LegalValuesFieldDefinition
    {
        private DDLFieldOfCodes field;
        private string sourceTableName;
        private string textColumnName;

        /// <summary>
        /// Default Constsructor for exclusive use by the designer
        /// </summary>
        public CodesFieldDefinition()
        {
            InitializeComponent();
        }

        		/// <summary>
		/// Constructor for the class
		/// </summary>
        /// <param name="frm">The parent form</param>
		/// <param name="page">The current page</param>
		public CodesFieldDefinition(MainForm frm, Page page) : base(frm)
		{
			InitializeComponent();
			this.mode = FormMode.Create;
			this.page = page;
		}
        
		/// <summary>
		/// Constructor for the class
		/// </summary>
        /// <param name="frm">The parent form</param>
		/// <param name="field">The fied to be edited</param>
		public CodesFieldDefinition(MainForm frm, DDLFieldOfCodes field) : base(frm)
		{
			InitializeComponent();
			this.mode = FormMode.Edit;
			this.field = field;
			this.page = field.Page;
			LoadFormData();
		}

        private void LoadFormData()
        {
            txtPrompt.Text = field.PromptText;
            txtFieldName.Text = field.Name;
            if (!string.IsNullOrEmpty(field.SourceTableName))
            {
                this.sourceTableName = field.SourceTableName;
                this.textColumnName = field.TextColumnName;
                txtDataSource.Text = field.SourceTableName + " :: " + field.TextColumnName;
            }
            chkReadOnly.Checked = field.IsReadOnly;
            chkRepeatLast.Checked = field.ShouldRepeatLast;
            chkRequired.Checked = field.IsRequired;
            promptFont = field.PromptFont;
            controlFont = field.ControlFont;
        }

        /// <summary>
        /// Sets the field's properties based on GUI values
        /// </summary>
        protected override void SetFieldProperties()
        {
            field.Name = txtFieldName.Text;
            field.PromptText = txtPrompt.Text;
            if (promptFont != null)
            {
                field.PromptFont = promptFont;
            }
            if (controlFont != null)
            {
                field.ControlFont = controlFont;
            }
            field.IsRequired = chkRequired.Checked;
            field.IsReadOnly = chkReadOnly.Checked;
            field.ShouldRepeatLast = chkRepeatLast.Checked;
            if (!string.IsNullOrEmpty(this.sourceTableName) && !string.IsNullOrEmpty(this.textColumnName))
            {
                field.SourceTableName = this.sourceTableName;
                field.TextColumnName = this.textColumnName;
            }
        }

        /// <summary>
        /// Gets the field defined by this field definition dialog
        /// </summary>
        public override RenderableField Field
        {
            get
            {
                return field;
            }
        }

        private void btnDataSource_Click(object sender, EventArgs e)
        {
            //DataSourceSelector selector = new DataSourceSelector(field, txtFieldName.Text);
            //DialogResult result = selector.ShowDialog();
            //if (result == DialogResult.OK)
            //{
            //    txtDataSource.Text = selector.TableName + " :: " + selector.ColumnName;
            //    this.sourceTableName = selector.TableName;
            //    this.textColumnName = selector.ColumnName;
            //}
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -