3

I am using DevExpress Xtragrid control in my C#.net windows application.

I enter some value into the first cell of the grid and if i go to second cell , the value entered in the first cell disappears.

How to retain the value entered in the cell ?

2 Answers 2

1

I am assuming that you are using this for an unbound column in a gridView (Xtragrid), first step is make sure to go to the column properties, and change the UnboundType property value to the datatype that you will be entering into that column, example below uses double.

Assign the CustomUnboundColumnData event to your gridView. Make sure that you declare a class level variable (named _userEnteredData in code sample below) to hold the value that you are entering into your gridView, then add the following piece of code, but make sure that you change the names to match your gridView and variable names:

Class level variable declaration:

private double _userEnteredData = 0;

Now the event:

private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
    if (e.Column == gridColumn_YourColumn && e.IsSetData)
    {
        _userEnteredData = Convert.ToDouble(e.Value);
    }
    else if (e.Column == gridColumn_YourColumn && e.IsGetData)
    {
        e.Value = _userEnteredData;
    }
}

I hope this helps.

You can get further details from here: http://documentation.devexpress.com/#WindowsForms/CustomDocument1477

1

Few possibilities:

  • check FieldName property of edited column. Maybe there is a typo, so grid does not pass your entered value to underlying datasource
  • property that is bound to column must have public setter. If there is only getter, grid also won't be capable to store entered value
  • check ColumnOptions.ReadOnly property in grid column - must be set to false

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.