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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16997 |

    Hi, I am using Xceed Grid. As per my requirement I need to show the default value in insertion cell, For that I created a MDataCellViewer and  MDataCellEditor Class inherited from NumericViewer and NumericEditor Class of Xceed Grid.

    I had override the function SetControlCoreValue to set the default value in cell.

    When I exceute my application then default values are showing on insertion cell, but when I cell comes in Editing mode then defulat value replaced by 0. In debug mode I had checked the value of cell that remains zero.  I need the set the default value as insertion cell value.

    Kindly help me to resolve this.

     

    Thanks & regards

    Vishwa

     

     

     

     

     

     

     

    Imported from legacy forums. Posted by vishwa (had 1481 views)

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.