Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IDataGridViewEditingControl.EditingControlFormattedValue Property

Gets or sets the formatted value of the cell being modified by the editor.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Object EditingControlFormattedValue { get; set; }

Property Value

Type: System.Object
An Object that represents the formatted value of the cell.

The formatted value represents the value as it is displayed in the control's user interface. The formatted value may be different in absolute value and even data type from the actual value contained in the control.

The following code example provides an implementation of this member. This example is part of a larger example available in How to: Host Controls in Windows Forms DataGridView Cells.

// Implements the IDataGridViewEditingControl.EditingControlFormattedValue  
// property. 
public object EditingControlFormattedValue
{
    get
    {
        return this.Value.ToShortDateString();
    }
    set
    {            
        if (value is String)
        {
            try
            {
                // This will throw an exception of the string is  
                // null, empty, or not in the format of a date. 
                this.Value = DateTime.Parse((String)value);
            }
            catch
            {
                // In the case of an exception, just use the  
                // default value so we're not left with a null 
                // value. 
                this.Value = DateTime.Now;
            }
        }
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft