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
230
How can I get the selected cell index from ActiveRecord
posted

Hi, I had to use SelectRecord as my data grid's CellClickAction, but when I clicked at a cell, I want to know the clicked cell index, is there any way I can get it?

 

  • 2125
    posted

    Hi,

    I don't know why you insist on using CellClickAction="SelectRecord"  in your  application.
    In answer to your question - "How can I get the selected cell index from ActiveRecord ?"
    I suggest you the following.

    In the Xaml file use this:  
     

    <Grid>
            <igDP:XamDataGrid Name="xamDataGrid1" BindToSampleData="True"  Margin="0,0,0,144"  SelectedItemsChanged="xamDataGrid1_SelectedItemsChanged">
               <igDP:XamDataGrid.FieldSettings>
                      <igDP:FieldSettings
                          CellClickAction="SelectCell"
                          AllowEdit="False"/>
               </igDP:XamDataGrid.FieldSettings>
          </igDP:XamDataGrid>
    </Grid>


    In the code behind use this:

    private void xamDataGrid1_SelectedItemsChanged(object sender, Infragistics.Windows.DataPresenter.Events.SelectedItemsChangedEventArgs e)
        {
           DataRecord selectedRecord = (DataRecord) xamDataGrid1.ActiveRecord;
           Cell selectedCell = xamDataGrid1.ActiveCell;
           CellCollection cellCollection = selectedRecord.Cells;
           int indxSelectedCell = cellCollection.IndexOf(selectedCell);
           MessageBox.Show("The index of the selected cell is :" + indxSelectedCell.ToString());
        }


    Best Regards,

    Yanko

  • 230
    posted

    Anybody can help me?