datagridview多加一行,看清楚在回
技术支持工程师 和 软件工程师 到底谁更好点
还有就是 怎么给datagridview多加一行 我的datagridview 不是托控件拖出来的 是代码写出来的
if (gvlist == null)
gvlist = new DataGridView();
gvlist.AllowUserToAddRows =false;
gvlist.AllowUserToDeleteRows = false;
gvlist.AllowUserToResizeRows =false;
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(210)))), ((int)(((byte)(225)))), ((int)(((byte)(240)))));
//dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
gvlist.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
gvlist.BackgroundColor = System.Drawing.Color.White;
gvlist.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
gvlist.Dock = System.Windows.Forms.DockStyle.Fill;
gvlist.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(210)))), ((int)(((byte)(225)))), ((int)(((byte)(240)))));
//gvlist.Location = new System.Drawing.Point(3, 103);
//gvlist.Name = "gvlist";
gvlist.ReadOnly = true;
gvlist.RowHeadersVisible = false;
gvlist.RowTemplate.Height = 23;
gvlist.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
//gvlist.TabIndex = 9;
gvlist.MultiSelect = false;
gvlist.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
gvlist.VirtualMode = true;
//gvlist.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(gvlist_CellMouseDoubleClick);
return gvlist;
我想在加一行 显示“总计” 这行
[解决办法]
gvlist.Rows.Add(new object[] {列1,列2,...});
列的顺序和你空间中列的顺序一直就可以了