locked
How to delete multiple rows in CGridctrl? RRS feed

  • Question

  • How to delete multiple rows in CGridctrl?
    Friday, April 27, 2018 1:13 PM

Answers

  • How to delete multiple rows in CGridctrl?

    Hello,

    as far as I know, you cannot delete (selected) rows directly. You must build the grid again.

    For example you can get the selected rows first that you want to delete. See your question before you to get it. Then you can refill the new grid. If a row is found that you wanted to delete, continue without filling it.

    Regards, Guido

    • Marked as answer by sgrm123 Friday, April 27, 2018 2:02 PM
    Friday, April 27, 2018 1:55 PM

All replies

  • How to delete multiple rows in CGridctrl?

    Hello,

    as far as I know, you cannot delete (selected) rows directly. You must build the grid again.

    For example you can get the selected rows first that you want to delete. See your question before you to get it. Then you can refill the new grid. If a row is found that you wanted to delete, continue without filling it.

    Regards, Guido

    • Marked as answer by sgrm123 Friday, April 27, 2018 2:02 PM
    Friday, April 27, 2018 1:55 PM
  • How to delete multiple rows in CGridctrl?

    Hello,

    as far as I know, you cannot delete (selected) rows directly. You must build the grid again.

    For example you can get the selected rows first that you want to delete. See your question before you to get it. Then you can refill the new grid. If a row is found that you wanted to delete, continue without filling it.

    Regards, Guido

    I tried this code and it is working for me.

    vector<unsigned int> vec;
    	int nFixed = m_ctrlScreensList.GetFixedRowCount();
    	int nCount = m_ctrlScreensList.GetRowCount()-1;
    
        // Delete all data rows
        for (int nRow = nCount; nRow >= nFixed; nRow--)
    	{
    		if (m_ctrlScreensList.IsCellSelected(nRow, 1))
    			vec.push_back(nRow);
    	}
    	for (int i=0;i<vec.size();i++)
    			m_ctrlScreensList.DeleteRow(vec[i]);
    
    	m_ctrlScreensList.Invalidate();


    • Edited by sgrm123 Friday, April 27, 2018 2:01 PM
    Friday, April 27, 2018 2:01 PM