Home Forums WinForms controls Xceed Grid for WinForms SelectedRowsChanged event and NullReferenceException

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15624 |

    I’m having a problem with the SelectedRowsChanged event Xceed Grid. I believe it is version 2.5.

    When selecting one row in the grid, the code in the SelectedRowsChanged event handler works as expected. However, when there are two or more rows selected, the code fails. I’m receiving a NullReferenceException on the “dataRow.Cells[“Status”].Value” line. It seems very odd that getting the value of a cell would result in a NullRefrenceException, when I know that the cell itself is not null.

    Any help would be greatly appreciated!

    private void gridSearchResults_SelectedRowsChanged(object sender, EventArgs e)
    {
    try
    {
    if (gridSearchResults.SelectedRows.Count > 0)
    {
    Xceed.Grid.DataRow dataRow = (Xceed.Grid.DataRow)gridSearchResults.SelectedRows[0];
    if (dataRow != null)
    {
    if (dataRow.Cells[“Status”] != null)
    {
    string contractStatus = (string)dataRow.Cells[“Status”].Value;

    // . . . . Do some work here
    }
    }
    }
    }
    }
    catch (Exception ex)
    {
    // handle exception
    }
    }

    Imported from legacy forums. Posted by Michael (had 1848 views)

    Xceed Support
    Member
    Post count: 5658

    I tried to reproduce you issue using the same code and was not able to reproduce.

    Would it be possible for you to send a sample application reproducing the issue to <a href=”mailto:support@xceedsoft.com”>support</a>, so we can investigate this further?

    Imported from legacy forums. Posted by CharlesB (had 2912 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.