$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 > Convert Data Types in C#

C# Data Types Converting for Grid Control

The DataGrid Controls for Windows Forms applications are an amazing component for design modern user interface. This cool control provides large flexibility to meet any critical requirements of applications nowadays. Furthermore, the DataGrid View control provides the .NET WinForms Data Type Converter to change the incompatible value types to supported ones.

Data Types Converting in C#

When we want to convert the data types, we can implement a custom data type converter class to control the Data Grid component to detect the types of data by using the Data Type Check Box Column. The following sample shows how to implement the toggle state converter c# class to convert the char values to toggle state values.

Apply Data Type Converters

When we apply the data type converters to Data Grid converting layer, we can use each of the two ways below. One is to apply the data type converters to generate the desired column and assign the data type property. The other is to add data type converters to use the DataTypeConverterAttribute specifying the Data TypeConverter. The following C# code shows how to apply the Data Type converters.

private void ConvertDataTypes_Load(object sender, EventArgs e)
{
GridCheckBoxColumn checkBox = new GridCheckBoxColumn("Organic", "IsOrganic");
checkBox.DataTypeConverter = new ToggleStateConverter();
this.ketticGrid.Columns.Add(checkBox);
}
To add data type converters to use the DataTypeConverterAttribute specifying the Data TypeConverter, we need to apply the DataTypeConverterAttribute to the incompatible property of the business object as data source, which generate data grid check box column.

public class Student
{
public int StudentID { get; set; }

public string StudentName { get; set; }
public string Class { get; set; }
public int StudentInClass { get; set; }
public double ClassNumber { get; set; }

[TypeConverter(typeof(ToggleStateConverter))]
public char IsOrganic { get; set; }
public double DeliveryAddress { get; set; }
}

Null Values in Data Grid

When there are null values in your data source, the Kettic Data Grid Control conversation layer can handle them. It requires to specify the default value committed to data source to null. The C# code below demonstrates how to set the Data source null value.

this.ketticGrid.Columns["StudentName"].DataSourceNullValue = "Input Student Name";
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