Rows not de-selecting

2 posts, 0 answers
  1. Nordy
    Nordy avatar
    14 posts
    Member since:
    Aug 2007

    Posted 03 Mar 2008 Link to this post

    I'm using the following code to select rows in a control that I've derived from the RadGridView control that has already been populated with data:

    public void SelectRows(DataTable tbl)  
    {  
       foreach (DataRow row in tbl.Rows)  
          this.Rows[_KeyMappings[Convert.ToInt32(row[_KeyMember])]].IsSelected = true;  
       if (tbl.Rows.Count > 0)  
          this.CurrentRow = this.SelectedRows[0];  
       this.Update();  

    _KeyMappings is a Dictionary<int, int> that maps primary key values to row indecies, and _KeyMember defines what the primary key is.  This works great, until the user tries to click on a row.  I'd LIKE the selected rows to clear out (since the user just picked a new one), as the code above is simply for setting the start up state of the control from data, but they don't.  When the user clicks a new row, any previously selected rows should become unselected.
  2. Nordy
    Nordy avatar
    14 posts
    Member since:
    Aug 2007

    Posted 03 Mar 2008 Link to this post

    Scratch that.  Apparently, it was because the SelectionMode property was set to CellSelect.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top