Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1150
How to initialize the AddNew record by code
posted

Hello,

My grid provides the AddNew record, 
but additionally I want the user to be able to create a new record by a keyboard shortcut and a ribbon button.
In the code behind the following code is executed when the user initiates this command:


grid.ExecuteCommand(DataPresenterCommands.EndEditModeAndCommitRecord);
grid.ActiveRecord = grid.RecordManager.CurrentAddRecord;
grid.ExecuteCommand(DataPresenterCommands.CellFirstInRecord);
grid.ExecuteCommand(DataPresenterCommands.StartEditMode);
 

This commits and current editing, activates the AddNewRecord line and puts the first cell in edit mode.
So far - so good.

Unfortunately the underlying business object is not initialized by this action.
Only when the user starts typing, the object is created and initialized.
How can I bring the grid to do this initializing on its own?

Thank you for any hint. 

BTW: how can I paste code with syntax highlighting?
I even tried the paste-from-word thing, but after inserting the coloring and formatting is gone... 

Parents Reply Children