$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Data Grid WinForms Control
Create data gird view in C# with modern user interface for your Windows Forms applications
Home > WinForms UI Controls > User Manual > Decimal Column in C#

C# Grid Decimal Column

The Kettic Grid Decimal Column is able to show and edit the decimal data. It is possible to bind the Grid Decimal Column to fields of any numeric type. The Grid Decimal Column descends all features of the Kettic Data Grid Column parent class. So the Grid Column properties that are shared by the Grid Decimal Column class offer custom appearance and C# events for building custom decimal column as necessary.

Add Grid Decimal Column in C#


GridDecimalColumn decimalColumn = new GridDecimalColumn();
decimalColumn.Name = "DecimalColumn";
decimalColumn.HeaderText = "Product Weight";
decimalColumn.FieldName = "ProductWeight ";
decimalColumn.DecimalPlaces = 2;
ketticGrid1.MasterTemplate.Columns.Add(decimalColumn);

Add Default Value to Empty Cells

The following C# code snippet shows how to set a default value to the empty cells

void ketticGrid_CellEditorInitialized(object sender, GridCellEventArgs e)
{
GridSpinEditor spinEditor = this.ketticGrid.ActiveEditor as GridSpinEditor;
if (spinEditor != null)
{
if (spinEditor.Value == null)
{
spinEditor.Value = 0.0;
}
}
}

Set Buttons of Spin Editor in C#

We can easily disable the up and down buttons of the spin editor in C# code snippet below.

void ketticGrid_CellEditorInitialized1(object sender, GridCellEventArgs e)
{
GridSpinEditor spinEditor = this.ketticGrid.ActiveEditor as GridSpinEditor;

((GridSpinEditorElement)spinEditor.EditorElement).DisplayUpDownButtons = false;
}

Set Decimal Position in C#

The Kettic Data Grid Control offers rich C# API to place the decimal in the spin editor of the column by assigning a value and set decimal position to column cells.

Place Decimal in C# to Spin Editor

To set the location of the decimal, we just need assign a value to the DecimalPlaces property in the spin editor.

decimalColumn.DecimalPlaces = 2;

Place Decimal in C# to Column Cells

This feature is able to determine how the decimal data to be shown in cells column. We just need to set the FormatString property of the Grid Decimal Column.

decimalColumn.FormatString = "{0:N1}";
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls