public partial class AcrossGrid : UserControl { /// <summary> /// 一页数量 /// </summary> private int _RowCount = 21; /// <summary> /// 数据源 /// </summary> public List<string> DataList { get; set; } = new List<string>(); public AcrossGrid() { InitializeComponent(); } /// <summary> /// 请空 /// </summary> public void Clear() { DataList.Clear(); tableLPClear(); label_YeShu.Text = "1/1"; } private void tableLPClear() { for (int i = 0; i < tableLP.Controls.Count; i++) { Label lbl = (Label)tableLP.Controls[i]; lbl.Text = ""; } } /// <summary> /// 加载数据 /// </summary> /// <param name="list">数据源</param> /// <param name="name">完整材料,缺少的材料,多的材料</param> public void Init(List<string> list) { Clear(); if (list == null || list.Count < 1) return; DataList = list; label_YeShu.Text = "1/" + (list.Count + _RowCount - 1) / _RowCount; LoadData(1, _RowCount); } /// <summary> /// /// </summary> /// <param name="pageNumber">页码</param> /// <param name="pageSize">页数</param> private void LoadData(int pageNumber, int pageSize) { tableLPClear(); int j = 0; for (int i = (pageNumber - 1) * pageSize; i < DataList.Count && j < pageSize; i++) { // // label5 // Label lbl = (Label)tableLP.Controls[j]; lbl.Text = DataList[i]; j++; } label_YeShu.Text = pageNumber + "/" + (DataList.Count + _RowCount - 1) / _RowCount; } private void btnNext_Click(object sender, EventArgs e) { string ys = label_YeShu.Text; string[] ysLst = ys.Split(‘/‘); if (int.Parse(ysLst[0]) >= int.Parse(ysLst[1])) return; LoadData(int.Parse(ysLst[0]) + 1, _RowCount); } private void btnLast_Click(object sender, EventArgs e) { string ys = label_YeShu.Text; string[] ysLst = ys.Split(‘/‘); if (int.Parse(ysLst[0]) <= 1) return; LoadData(int.Parse(ysLst[0]) - 1, _RowCount); } }
partial class AcrossGrid { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region 组件设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要修改 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.label_YeShu = new System.Windows.Forms.Label(); this.btnNext = new System.Windows.Forms.Button(); this.btnLast = new System.Windows.Forms.Button(); this.tableLP = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label(); this.label21 = new System.Windows.Forms.Label(); this.tableLP.SuspendLayout(); this.SuspendLayout(); // // label_YeShu // this.label_YeShu.BackColor = System.Drawing.Color.Transparent; this.label_YeShu.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label_YeShu.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label_YeShu.Location = new System.Drawing.Point(544, 354); this.label_YeShu.Name = "label_YeShu"; this.label_YeShu.Size = new System.Drawing.Size(66, 32); this.label_YeShu.TabIndex = 54; this.label_YeShu.Text = "1/1"; this.label_YeShu.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // btnNext // this.btnNext.BackgroundImage = global::LControls.Properties.Resources.next_xy; this.btnNext.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.btnNext.FlatAppearance.BorderSize = 0; this.btnNext.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnNext.Location = new System.Drawing.Point(610, 351); this.btnNext.Name = "btnNext"; this.btnNext.Size = new System.Drawing.Size(51, 38); this.btnNext.TabIndex = 53; this.btnNext.UseVisualStyleBackColor = true; this.btnNext.Click += new System.EventHandler(this.btnNext_Click); // // btnLast // this.btnLast.BackgroundImage = global::LControls.Properties.Resources.last_xy; this.btnLast.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.btnLast.FlatAppearance.BorderSize = 0; this.btnLast.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnLast.Location = new System.Drawing.Point(490, 351); this.btnLast.Name = "btnLast"; this.btnLast.Size = new System.Drawing.Size(51, 38); this.btnLast.TabIndex = 52; this.btnLast.UseVisualStyleBackColor = true; this.btnLast.Click += new System.EventHandler(this.btnLast_Click); // // tableLP // this.tableLP.BackColor = System.Drawing.Color.Transparent; this.tableLP.ColumnCount = 3; this.tableLP.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLP.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLP.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLP.Controls.Add(this.label1, 0, 0); this.tableLP.Controls.Add(this.label2, 0, 1); this.tableLP.Controls.Add(this.label3, 0, 2); this.tableLP.Controls.Add(this.label4, 0, 3); this.tableLP.Controls.Add(this.label5, 0, 4); this.tableLP.Controls.Add(this.label6, 0, 5); this.tableLP.Controls.Add(this.label7, 0, 6); this.tableLP.Controls.Add(this.label8, 1, 0); this.tableLP.Controls.Add(this.label9, 1, 1); this.tableLP.Controls.Add(this.label10, 1, 2); this.tableLP.Controls.Add(this.label11, 1, 3); this.tableLP.Controls.Add(this.label12, 1, 4); this.tableLP.Controls.Add(this.label13, 1, 5); this.tableLP.Controls.Add(this.label14, 1, 6); this.tableLP.Controls.Add(this.label15, 2, 0); this.tableLP.Controls.Add(this.label16, 2, 1); this.tableLP.Controls.Add(this.label17, 2, 2); this.tableLP.Controls.Add(this.label18, 2, 3); this.tableLP.Controls.Add(this.label19, 2, 4); this.tableLP.Controls.Add(this.label20, 2, 5); this.tableLP.Controls.Add(this.label21, 2, 6); this.tableLP.Location = new System.Drawing.Point(17, 12); this.tableLP.Name = "tableLP"; this.tableLP.RowCount = 7; this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F)); this.tableLP.Size = new System.Drawing.Size(1109, 336); this.tableLP.TabIndex = 55; // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label1.Location = new System.Drawing.Point(3, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(294, 31); this.label1.TabIndex = 0; this.label1.Text = "20755000010110000012"; // // label2 // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label2.Location = new System.Drawing.Point(3, 48); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(294, 31); this.label2.TabIndex = 1; this.label2.Text = "20755000010110000012"; // // label3 // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label3.Location = new System.Drawing.Point(3, 96); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(294, 31); this.label3.TabIndex = 2; this.label3.Text = "20755000010110000012"; // // label4 // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label4.Location = new System.Drawing.Point(3, 144); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(294, 31); this.label4.TabIndex = 3; this.label4.Text = "20755000010110000012"; // // label5 // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label5.Location = new System.Drawing.Point(3, 192); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(294, 31); this.label5.TabIndex = 4; this.label5.Text = "20755000010110000012"; // // label6 // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label6.Location = new System.Drawing.Point(3, 240); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(294, 31); this.label6.TabIndex = 5; this.label6.Text = "20755000010110000012"; // // label7 // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label7.Location = new System.Drawing.Point(3, 288); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(294, 31); this.label7.TabIndex = 6; this.label7.Text = "20755000010110000012"; // // label8 // this.label8.AutoSize = true; this.label8.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label8.Location = new System.Drawing.Point(372, 0); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(294, 31); this.label8.TabIndex = 7; this.label8.Text = "20755000010110000012"; // // label9 // this.label9.AutoSize = true; this.label9.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label9.Location = new System.Drawing.Point(372, 48); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(294, 31); this.label9.TabIndex = 8; this.label9.Text = "20755000010110000012"; // // label10 // this.label10.AutoSize = true; this.label10.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label10.Location = new System.Drawing.Point(372, 96); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(294, 31); this.label10.TabIndex = 9; this.label10.Text = "20755000010110000012"; // // label11 // this.label11.AutoSize = true; this.label11.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label11.Location = new System.Drawing.Point(372, 144); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(294, 31); this.label11.TabIndex = 10; this.label11.Text = "20755000010110000012"; // // label12 // this.label12.AutoSize = true; this.label12.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label12.Location = new System.Drawing.Point(372, 192); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(294, 31); this.label12.TabIndex = 11; this.label12.Text = "20755000010110000012"; // // label13 // this.label13.AutoSize = true; this.label13.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label13.Location = new System.Drawing.Point(372, 240); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(294, 31); this.label13.TabIndex = 12; this.label13.Text = "20755000010110000012"; // // label14 // this.label14.AutoSize = true; this.label14.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label14.Location = new System.Drawing.Point(372, 288); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(294, 31); this.label14.TabIndex = 13; this.label14.Text = "20755000010110000012"; // // label15 // this.label15.AutoSize = true; this.label15.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label15.Location = new System.Drawing.Point(741, 0); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(294, 31); this.label15.TabIndex = 14; this.label15.Text = "20755000010110000012"; // // label16 // this.label16.AutoSize = true; this.label16.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label16.Location = new System.Drawing.Point(741, 48); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(294, 31); this.label16.TabIndex = 15; this.label16.Text = "20755000010110000012"; // // label17 // this.label17.AutoSize = true; this.label17.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label17.Location = new System.Drawing.Point(741, 96); this.label17.Name = "label17"; this.label17.Size = new System.Drawing.Size(294, 31); this.label17.TabIndex = 16; this.label17.Text = "20755000010110000012"; // // label18 // this.label18.AutoSize = true; this.label18.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label18.Location = new System.Drawing.Point(741, 144); this.label18.Name = "label18"; this.label18.Size = new System.Drawing.Size(294, 31); this.label18.TabIndex = 17; this.label18.Text = "20755000010110000012"; // // label19 // this.label19.AutoSize = true; this.label19.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label19.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label19.Location = new System.Drawing.Point(741, 192); this.label19.Name = "label19"; this.label19.Size = new System.Drawing.Size(294, 31); this.label19.TabIndex = 18; this.label19.Text = "20755000010110000012"; // // label20 // this.label20.AutoSize = true; this.label20.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label20.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label20.Location = new System.Drawing.Point(741, 240); this.label20.Name = "label20"; this.label20.Size = new System.Drawing.Size(294, 31); this.label20.TabIndex = 19; this.label20.Text = "20755000010110000012"; // // label21 // this.label21.AutoSize = true; this.label21.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label21.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(117)))), ((int)(((byte)(117)))), ((int)(((byte)(117))))); this.label21.Location = new System.Drawing.Point(741, 288); this.label21.Name = "label21"; this.label21.Size = new System.Drawing.Size(294, 31); this.label21.TabIndex = 20; this.label21.Text = "20755000010110000012"; // // AcrossGrid // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.tableLP); this.Controls.Add(this.label_YeShu); this.Controls.Add(this.btnNext); this.Controls.Add(this.btnLast); this.Name = "AcrossGrid"; this.Size = new System.Drawing.Size(1143, 392); this.tableLP.ResumeLayout(false); this.tableLP.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Label label_YeShu; private System.Windows.Forms.Button btnNext; private System.Windows.Forms.Button btnLast; private System.Windows.Forms.TableLayoutPanel tableLP; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label21; private System.Windows.Forms.Label label20; private System.Windows.Forms.Label label19; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label11; private System.Windows.Forms.Label label12; private System.Windows.Forms.Label label13; private System.Windows.Forms.Label label15; private System.Windows.Forms.Label label14; private System.Windows.Forms.Label label16; private System.Windows.Forms.Label label17; private System.Windows.Forms.Label label18; }
作者:三小
声明:原创博客请在转载时保留原文链接或者在文章开头加上本人博客地址,如发现错误,欢迎批评指正。凡是转载于本人的文章,不能设置打赏功能,如有特殊需求请与本人联系!