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
2320
Retrieve Cell Editors?
posted

Is there any way to retrieve a specific cell's editor from a record in XamDataGrid from codebehind? Apart from in the XamDataGrid's EditMode events?

Parents
  • 2677
    Verified Answer
    posted

    Hello,

     You can get the editor from a cell if you have the CellValuePresenter.  The way to do this would be using the static method FromCell or FromRecordAndField in the CellValuePresenter class.  The code will be similar to this:

    DataRecord dr = this.xamDataGrid1.Records[0] as DataRecord;

    CellValuePresenter cvp = CellValuePresenter.FromCell(dr.Cells[0]);

    //CellValuePresenter cvp = CellValuePresenter.FromRecordAndField(dr, dr.FieldLayout.Fields[0]);

    XamComboEditor xce = cvp.Editor as XamComboEditor;

    However, the time at which these presenters are created is very late in the window lifecycle.  You will want to use a very late event off of the page called ContentRendered if you want to take a look at the editors on the initial window load. 

    However, if you want to get at the editors after the window has already loaded, just use the code above.  Remember, you will have to loop through the records to get all the Editors. 

     Hope this helps!

Reply Children
No Data