Home Forums WinForms controls Xceed Grid for WinForms Set the default value in insertion cell Reply To: Set the default value in insertion cell

User (Old forums)
Member
Post count: 23064

You can use the IdleValue property on the InsertionCell class.  Moreover, you can set the Value property once the DataRow is actually added to the grid, in the EditBegun method.  This way you will not have to override SetControlValueCore(), since the cell value will already be set, and the editor will automatically draw its value from it.

e.g.:

    private void Form1_Load( object sender, EventArgs e )
    {
      ( ( InsertionCell )insertionRow1.Cells[ 1 ]).IdleValue = “this is a default value”;

      insertionRow1.EditBegun += new EventHandler( insertionRow1_EditBegun );
    }

    void insertionRow1_EditBegun( object sender, EventArgs e )
    {
      InsertionRow row = sender as InsertionRow;
      //Take the idle value of the InsertionCell and set it on the Value property of the underlying DataRow which you access through the InsertionRow itself.
      row.Cells[ 1 ].Value = ( ( InsertionCell )row.Cells[ 1 ] ).IdleValue;
    }

Imported from legacy forums. Posted by André (had 2047 views)