DataGrid group ---- general functions

Source: Internet
Author: User

# Region formatdg
Private void formatgrid (DataGrid DG, int T)
{
If (DG. Items. Count! = 0)
{
Int begin = 0; // merge the same customer names. Begin is the first column.
Int end = 0; // end is the end column.
String pre = DG. items [0]. cells [T]. Text; // mark, indicating the first column with the same customer name
String cur; // the name of the next customer
For (INT I = 0; I <DG. Items. Count; I ++)
{
Cur = DG. items [I]. cells [T]. text;
If (cur! = Pre) // if the names of the first and second customers are different
{
End = I-1;
Pre = cur; // pre becomes the new customer name
If (end> begin)
{
For (Int J = begin + 1; j <= end; j ++) // clears the same customer name from begin to end.
{
DG. items [begin]. cells [T]. rowspan = end-begin + 1;
DG. items [J]. cells [T]. Visible = false;
// DG. items [J]. cells. removeat (0 );
}
}
Else // the last group of customers
{
End = DG. Items. count;
For (Int J = begin + 1; j <end; j ++)
{
DG. items [begin]. cells [T]. rowspan = end-begin;
DG. items [J]. cells [T]. Visible = false;
// DG. items [J]. cells. removeat (0 );
}
}
Begin = I;
}
Else // only has one group of identical Customer names
{
End = DG. Items. count;
If (I = DG. Items. Count-1)
{
For (Int J = begin + 1; j <end; j ++)
{
DG. items [begin]. cells [T]. rowspan = end-begin;
DG. items [J]. cells [T]. Visible = false;
// DG. items [J]. cells. removeat (0 );
}
}

}

}

}

}
# Endregion

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.