The NumericEdit control is a control derived from the TextBox control which accepts numeric type values only. It comes with spin up and spin down buttons to increment or decrement the numeric values. The control supports various numeric formats including Currency, DateTime, Scientific etc. using the FormatType property. You can set the Increment property to specify the interval by which spin buttons should increment or decrement the value. Moreover, NumericEdit lets you increase or decrease the values programmatically using SpinUp() or SpinDown() methods provided by the class.
Add NumericEdit Control |
Copy Code
|
---|---|
numEdit = new C1NumericEdit(); Controls.Add(numEdit); numEdit.Location = new Point(10, 170); numEdit.Size = new Size(100, 30); numEdit.Text = "12"; numEdit.NumericInputKeys = NumericInputKeys.All; numEdit.Increment = "3"; |
The NumericEdit control consists of two parts: textbox and spin buttons.
TextBox: This is the are which displays the value. In NumericEdit control, the textbox can accept only numeric type values.
Spin Up/Down Buttons: These are the buttons provided to change the value of the control just by clicking. UpDownButtonClick event is fired each time these buttons are clicked.
Binding a control with a data source gives you ability to communicate and even update the underlying data through the control. The NumericEdit control can be bound to numeric type fields like Integer, DateTime etc. of a data source using DataSource property of the C1NumericEdit class. You can specify the field to be bound to control using the DataMember property.
Data binding in NumericEdit |
Copy Code
|
---|---|
c1NumericEdit1.DataSource = bSource; c1NumericEdit1.DataMember = "ProductID"; c1NumericEdit1.DataType = typeof(int); |