Ejemplo n.º 1
0
        private void DataGridTextBoxColumn_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            System.Windows.Forms.DataGridTextBox gtbcColumn = (System.Windows.Forms.DataGridTextBox)sender;
            bool bPossuiVirgula = (gtbcColumn.Text.IndexOf(",") != -1);
            bool bNovaVirgula   = (e.KeyChar == '.') || (e.KeyChar == ',');

            if (e.KeyChar != 8)
            {
                if (((48 <= (int)e.KeyChar) && ((int)e.KeyChar <= 57)) || (bNovaVirgula && !bPossuiVirgula))
                {
                    if (e.KeyChar == '.')
                    {
                        int    nPos = gtbcColumn.SelectionStart;
                        string strTextoAnterior;
                        string strTextoPosterior;
                        strTextoAnterior          = gtbcColumn.Text.Substring(0, nPos);
                        strTextoPosterior         = gtbcColumn.Text.Substring(nPos);
                        gtbcColumn.Text           = strTextoAnterior + "," + strTextoPosterior;
                        gtbcColumn.SelectionStart = nPos + 1;
                        e.Handled = true;
                    }
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
Ejemplo n.º 2
0
 public DataGridCASSparrow()
     : base(true)
 {
     _dgrtxt = (DataGridTextBox)txt;
     //_dgrtxt.GotFocus += new EventHandler (DoTxtGotFocus);
     //txt.Validated += new EventHandler(OnTextValidated);
 }
 public DataGridCASSelectFromTV(bool aIsDataGridTextBox)
     : base(aIsDataGridTextBox)
 {
     if (aIsDataGridTextBox)
         _dgrtxt = (DataGridTextBox)txt;
     else
         _dgrtxt = null;
 }
Ejemplo n.º 4
0
 public DataGridTextBoxColumn(PropertyDescriptor prop, string format, bool isDefault) : base(prop, isDefault)
 {
     edit               = new DataGridTextBox();
     edit.BorderStyle   = BorderStyle.None;
     edit.Multiline     = true;
     edit.AcceptsReturn = true;
     edit.Visible       = false;
     this.Format        = format;
 }
Ejemplo n.º 5
0
 public DataGridTextBoxColumn(PropertyDescriptor prop, string format, bool isDefault) : base(prop, isDefault)
 {
     edit = new DataGridTextBox
     {
         BorderStyle   = BorderStyle.None,
         Multiline     = true,
         AcceptsReturn = true,
         Visible       = false
     };
     Format = format;
 }
Ejemplo n.º 6
0
		public DataGridTextBoxColumn (PropertyDescriptor prop,  string format, bool isDefault) : base (prop)
		{
			Format = format;
			is_default = isDefault;

			textbox = new DataGridTextBox ();
			textbox.Multiline = true;
			textbox.WordWrap = false;
			textbox.BorderStyle = BorderStyle.None;
			textbox.Visible = false;
		}
Ejemplo n.º 7
0
        public DataGridTextBoxColumn(PropertyDescriptor prop, string format, bool isDefault) : base(prop)
        {
            Format     = format;
            is_default = isDefault;

            textbox             = new DataGridTextBox();
            textbox.Multiline   = true;
            textbox.WordWrap    = false;
            textbox.BorderStyle = BorderStyle.None;
            textbox.Visible     = false;
        }
 public DataGridTextBoxColumn(System.ComponentModel.PropertyDescriptor prop, string format, bool isDefault) : base(prop, isDefault)
 {
     this.xMargin = 2;
     this.yMargin = 1;
     this.editRow = -1;
     this.edit = new DataGridTextBox();
     this.edit.BorderStyle = BorderStyle.None;
     this.edit.Multiline = true;
     this.edit.AcceptsReturn = true;
     this.edit.Visible = false;
     this.Format = format;
 }
 public DataGridTextBoxColumn(System.ComponentModel.PropertyDescriptor prop, string format, bool isDefault) : base(prop, isDefault)
 {
     this.xMargin            = 2;
     this.yMargin            = 1;
     this.editRow            = -1;
     this.edit               = new DataGridTextBox();
     this.edit.BorderStyle   = BorderStyle.None;
     this.edit.Multiline     = true;
     this.edit.AcceptsReturn = true;
     this.edit.Visible       = false;
     this.Format             = format;
 }
Ejemplo n.º 10
0
        protected internal override void ReleaseHostedControl()
        {
            if (textbox == null)
            {
                return;
            }

            grid.SuspendLayout();
            grid.Controls.Remove(textbox);
            grid.Invalidate(new Rectangle(textbox.Location, textbox.Size));
            textbox.Dispose();
            textbox = null;
            grid.ResumeLayout(false);
        }
Ejemplo n.º 11
0
		protected internal override void ReleaseHostedControl ()
		{
			if (textbox == null)
				return;

			grid.SuspendLayout ();
			grid.Controls.Remove (textbox);
			grid.Invalidate (new Rectangle (textbox.Location, textbox.Size));
			textbox.Dispose ();
			textbox = null;
			grid.ResumeLayout (false);
		}
Ejemplo n.º 12
0
        public void TestBindingToDataGridTextBox()
        {
            DataGridTextBox control = new DataGridTextBox();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                DataGridTextBox bindableTarget = scope.CreateTarget(control);
                int dataBindingsBeforeText = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Text);

                Assert.AreEqual(dataBindingsBeforeText + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Text, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Text, obj.Name);

                int dataBindingsBeforeMaxLength = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.MaxLength);

                Assert.AreEqual(dataBindingsBeforeMaxLength + 1, control.DataBindings.Count);

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.MaxLength, obj.IntValue);

                int dataBindingsBeforeSelectionLength = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionLength);

                Assert.AreEqual(dataBindingsBeforeSelectionLength + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionLength, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionLength, obj.IntValue);

                int dataBindingsBeforeSelectionStart = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.SelectionStart);

                Assert.AreEqual(dataBindingsBeforeSelectionStart + 1, control.DataBindings.Count);

                Assert.AreEqual(control.SelectionStart, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.SelectionStart, obj.IntValue);

                int dataBindingsBeforeAccessibleDefaultActionDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDefaultActionDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDefaultActionDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDefaultActionDescription, obj.Name);

                int dataBindingsBeforeAccessibleDescription = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleDescription);

                Assert.AreEqual(dataBindingsBeforeAccessibleDescription + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleDescription, obj.Name);

                int dataBindingsBeforeAccessibleName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.AccessibleName);

                Assert.AreEqual(dataBindingsBeforeAccessibleName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.AccessibleName, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.AccessibleName, obj.Name);

                int dataBindingsBeforeLeft = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Left);

                Assert.AreEqual(dataBindingsBeforeLeft + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Left, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Left, obj.IntValue);

                int dataBindingsBeforeName = control.DataBindings.Count;

                scope.Bind(bindableSource.Name).To(bindableTarget.Name);

                Assert.AreEqual(dataBindingsBeforeName + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Name, obj.Name);

                obj.ChangeName();

                Assert.AreEqual(control.Name, obj.Name);

                int dataBindingsBeforeTabIndex = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.TabIndex);

                Assert.AreEqual(dataBindingsBeforeTabIndex + 1, control.DataBindings.Count);

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.TabIndex, obj.IntValue);

                int dataBindingsBeforeTop = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Top);

                Assert.AreEqual(dataBindingsBeforeTop + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Top, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Top, obj.IntValue);

                int dataBindingsBeforeWidth = control.DataBindings.Count;

                scope.Bind(bindableSource.IntValue).To(bindableTarget.Width);

                Assert.AreEqual(dataBindingsBeforeWidth + 1, control.DataBindings.Count);

                Assert.AreEqual(control.Width, obj.IntValue);

                obj.ChangeIntValue();

                Assert.AreEqual(control.Width, obj.IntValue);

            }
        }
Ejemplo n.º 13
0
 public DataGridTextBoxColumn(PropertyDescriptor prop, string format, bool isDefault) : base(prop, isDefault) {
     edit = new DataGridTextBox();
     edit.BorderStyle = BorderStyle.None;
     edit.Multiline = true;
     edit.AcceptsReturn = true;
     edit.Visible = false;
     this.Format = format;
 }