2015-04-22 48 views
1

如何在infragistics xamdatagrid中找到基于ActiveRecord或ActiveCell的cellvaluepresenter?在Active cell(XamDataGrid)中查找编辑器infragistics

我尝试了下面的代码,但它在单元格值演示器中给null。

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(); 

} 

这是结合

<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> 

所以现在我想通过该事件找到激活记录,找到编辑类型并启动编辑模式。

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

对我来说工作正常,但它调用单元格编辑模式而不是编辑器(内部控件)。

我想在激活的单元格中找到该编辑器并使其开始可编辑类型。

回答

1

您可以使用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(); 
    } 
+0

u能张贴代码复制乌尔问题。像数据模型,结合等。 –

+0

对不起,我改变了我的问题bcoz突然我注意到我我以前不使用cellvaluepresenter我上面mentiod绑定设置\ – Saurabhchauhan232

0

你可以尝试从使用的GetChildCellValuePresenters()方法从RecordActivatedEventArgs得到它。

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

然后,您必须筛选您需要的cellValuePresenter阵列。

编辑:已更新代码以获取cellValuePresenters,忘记将其投射到DataRecordPresenter上。但既然你说过你的问题不同,我会再看一遍。

+0

已经用做u怎么弄这个方法,当我试图写e.Record.GetChildCellValuePresenters()它不可用在RecordActivatedEventArgs事件 – Saurabhchauhan232

0

使用下面的代码:(如果你已经有了CellValuePresenter

 CellValuePresenter cvp = new CellValuePresenter(); 

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

EditorInfragistics库从ValueEditor得来,所以使用它作为一个裁判Editor

相关问题