Completed
Last Updated: 07 Dec 2016 07:42 by ADMIN
ADMIN
Dimitar
Created on: 05 Dec 2016 07:02
Category: GridView
Type: Bug Report
0
FIX. RadGridView - the MaxLength of the TextBoxColumn is not respected when pasting and the cell is not in edit mode.
To reproduce:
- Add GridViewTextBoxColumn and set the MaxLength property.
- Paste in data row while the is not in edit mode.

Workaround:
private void RadGridView1_Pasting(object sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e)
{
    if (radGridView1.CurrentColumn.Name == "column1")
    {
        GridViewTextBoxColumn col = new GridViewTextBoxColumn();
        var lenght = col.MaxLength;
        if (Clipboard.ContainsData(DataFormats.Text))
        {
            e.Cancel = true;
            string data = Clipboard.GetData(DataFormats.Text).ToString();
            radGridView1.CurrentCell.Value = data.Substring(0, lenght);
        }
    }
}

 
0 comments