Пример #1
0
        public Form1()
        {
            InitializeComponent();
            Random rnd = new Random(DateTime.Now.Millisecond);

            dt.Columns.Add("Latitude");
            dt.Columns.Add("Longitude");
            dataGridView1.AutoGenerateColumns = false;
            for (int i = 0; i < 5; i++)
            {
                dt.Rows.Add(rnd.Next(1000000000, 1800000000), rnd.Next(100000000, 1000000000));
            }
            dataGridView1.DataSource = dt;

            MaskedEditColumn col = new MaskedEditColumn("lon");

            col.DataPropertyName = "Longitude";
            col.HeaderText       = "Широта";
            col.Name             = col.DataPropertyName;
            dataGridView1.Columns.Add(col);

            col = new MaskedEditColumn("lat");
            col.DataPropertyName = "Latitude";
            col.HeaderText       = "Долгота";
            col.Name             = col.DataPropertyName;
            dataGridView1.Columns.Add(col);
        }
Пример #2
0
        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            MaskedEditColumn  mec    = OwningColumn as MaskedEditColumn;
            MaskedEditControl mectrl = (MaskedEditControl)DataGridView.EditingControl;

            try {
                mectrl.Text = this.Value.ToString();
            }
            catch (Exception) {
                mectrl.Text = string.Empty;
            }
            mectrl.Mask           = mec.Mask;
            mectrl.PromptChar     = mec.PromtChar;
            mectrl.ValidatingType = mec.ValidatingType;
        }