Share two-segment row-and-column merging algorithms

Source: Internet
Author: User

Implements a multi-complex header style with a GridView horizontal vertical merge column of the specified row and column

Call:

Gridcommon.unitelist (THIS.GRID1, 4);

Gridcommon.groupcol (THIS.GRID1, 4, dt. Columns.count);

        <summary>////Horizontal merge column///</summary> public static void Unitelist (GridView GV, int rowIndex) {if (GV.            Rows.Count < 1) {return;            } TableRow tr; for (int i = 0; i < RowIndex; i++) {tr = gv.                Rows[i]; if (GV. Rows[i].                Cells.count < 1) {return; } TableCell Otcell = GV. Rows[i].                Cells[0]; Otcell. BackColor = System.Drawing.Color.FromArgb (219, 234, 253);                System.Drawing.Color.Teal; Otcell.                HorizontalAlign = Horizontalalign.center; for (int j = 1; J < GV. Rows[i]. Cells.count; J + +) {TableCell Tcell = gv. Rows[i].                    CELLS[J]; if (Tcell. Text = = Otcell. Text) {Tcell.                        Visible = false; if (Otcell.   ColumnSpan = = 0)                     {Otcell.                        ColumnSpan = 1; } Otcell.                        columnspan++; Otcell.                        VerticalAlign = Verticalalign.middle; Otcell.                        HorizontalAlign = Horizontalalign.center; Otcell. BackColor = System.Drawing.Color.FromArgb (219, 234, 253); system.drawing.color.teal;213, 237, 249 Otcell.                    Wrap = false;                        } else {Otcell = Tcell; Otcell.                        HorizontalAlign = Horizontalalign.center; Otcell.                    BackColor = System.Drawing.Color.FromArgb (219, 234, 253);//system.drawing.color.teal; }}}}///<summary>///Vertical merge columns///</summary>//  /<param name= "GV" >GridView</param>///<param Name= "Colindex" > Combined column ordinal number </param>      public static void Groupcol (GridView gv, int rowIndex, int cellindex) {if (GV.            Rows.Count < 1) {return;            } TableRow tr; for (int j = 0; J < CellIndex; J + +) {TableRow OLDTR = gv.                Rows[0]; for (int i = 1; i < RowIndex; i++) {tr = gv.                    Rows[i]; if (Oldtr.cells[j]. Text = = tr. CELLS[J]. Text) {tr. CELLS[J].                        Visible = false; if (Oldtr.cells[j]. RowSpan = = 0) {Oldtr.cells[j].                        RowSpan = 1; } Oldtr.cells[j].                        rowspan++;                    Oldtr.verticalalign = Verticalalign.middle;                    } else {oldtr = tr; }                }            }        }

  

Share two-segment row-and-column merging algorithms

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.