Dev GridView gets all data rows under the selected group Z

Source: Internet
Author: User

Now it's time to implement such a feature in the DevExpress GridView. is to determine whether the current selected row is a grouped row, and if so, to get all the data information under that grouping.

such as (the group in the Red Box is selected to act.) Program to get all the data under the group)


The implementation code is as follows:

 list<int> _gridviewrowindexs = new list<int> ();  Stores the selected row index in the GridView private void Test () {int[] rows = gridview1.getselectedrows ();//Get GridView The selected data row information for (int i = 0; i < rows. Count ();        i++) _gridviewrowindexs = Fildrowsnotgroupindex (Rows[i]);            }//Gets all data row indexes under grouping (for cases with multilevel groupings) private list<int> fildrowsnotgroupindex (int rowIndex) {            List<int> returnvalue = new list<int> ();                BOOL IsGroup = Gridview1.isgrouprow (RowIndex);//Determines whether the current row index is a grouped row if (IsGroup = = False) {            Returnvalue.add (RowIndex);                } else {int count = Gridview1.getchildrowcount (rowIndex);//Gets the number of data under the current grouping for (int j = 0; J < Count; J + +) {int childrowindex = Gridview1.getchildrowhandle ( RowIndex, j);//Gets the row index of the record Returnvalue.addrange under the current grouping (fildrowsnotGroupindex (Childrowindex).                ToArray ());        }} return returnvalue; }

Gets the row index _gridviewrowindexs is the row index in the GridView. If you want to get the row index of the bound data source.

int datatableindex = Gridview1.getdatasourcerowindex (item);  Converts a row index in a GridView to a row index in a bound data source

Dev GridView gets all data rows under the selected group Z

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.