Saurabhchauhan232
Saurabhchauhan232

Reputation: 89

Find Editor inside Active cell (XamDataGrid) infragistics

How do i find cellvaluepresenter based on ActiveRecord or ActiveCell in infragistics xamdatagrid?

I tried below code but it is giving null in cell value presenter.

    private void grdGrid_RecordActivated(object sender,RecordActivatedEventArgs e)
    {          

  (grdGrid.ActiveRecord as DataRecord).Cells["fldDescription"].IsActive = true;

            Cell selectedCell = grdGrid.ActiveCell;

            CellValuePresenter cvp = CellValuePresenter.FromCell(selectedCell);

            cvp.Editor.StartEditMode();

}

this is binding

<igDP:UnboundField  Name="fldDescription" Label="Description" BindingPath="TaskItemAction.Description" BindingMode="TwoWay">
                                                            <igDP:Field.Settings>
                                                                <igDP:FieldSettings CellClickAction="EnterEditModeIfAllowed" EditorStyle="{StaticResource textStyleKey}" EditorType="{x:Type editors:XamTextEditor}" EditAsType="{x:Type sys:String}" 
                                                        CellWidth="30" CellHeight="30" AllowEdit="True" Width="0.4*" Height="30" >

                                                                </igDP:FieldSettings>
                                                            </igDP:Field.Settings>

So now i want to find Activated record by that event and find editor type and start edit mode.

    private void GrdTaskItemAction_RecordActivated(object sender, RecordActivatedEventArgs e)
            {
    grdGrid.ExecuteCommand(DataPresenterCommands.StartEditMode);
} 

is working fine for me but it is calling edit mode for the cell not the editor(control inside it).

I want to find that editor inside activated cell and make it start editable type.

Upvotes: 1

Views: 2642

Answers (3)

Kylo Ren
Kylo Ren

Reputation: 8823

Use below code:(If you already have the CellValuePresenter)

      CellValuePresenter cvp = new CellValuePresenter();

        ValueEditor VE = Infragistics.Windows.Utilities.GetDescendantFromType(cvp, typeof(ValueEditor), true) as ValueEditor;
        if (VE != null)
        {
            VE.IsInEditMode = true;
        }

Every Editor in Infragistics Lib is derived from ValueEditor, so use that as a ref to Editor.

Upvotes: 0

Mike Nowak
Mike Nowak

Reputation: 333

You could try from getting it from the RecordActivatedEventArgs using the the GetChildCellValuePresenters() method.

var cellValuePresenters = ((DataRecordPresenter)e.Record).GetChildCellValuePresenters()

Then you have to filter the array for the cellValuePresenter you need.

Edit: updated the code to cet the cellValuePresenters, forgot to cast it on DataRecordPresenter. But since you said your problem is different, I will look into it again.

Upvotes: 0

Ayyappan Subramanian
Ayyappan Subramanian

Reputation: 5366

You can directly get the cell using activerecord.

 private void grdGrid_RecordActivated(object sender, Infragistics.Windows.DataPresenter.Events.RecordActivatedEventArgs e)
    {
        Cell selectedCell = (grdGrid.ActiveRecord as DataRecord).Cells["fldDescription"];

        CellValuePresenter cvp = CellValuePresenter.FromCell(selectedCell);

        cvp.Editor.StartEditMode();
    }

Upvotes: 1

Related Questions