在窗体上定义了一个datagridview,datagridview的高度只够显示20行记录,初始时datagridview为空,程序动态地往datagridview中添加新行,当总函数未超过20行时没有异常,但是当超过21行时,滚动条无法显示,而且整个程序处于假死状态(通过查看日志文件,确定程序还在正常运行)
而如果通过直接查询数据库,记录行数超过21行就可以显示滚动条,一切都正常,为什么动态添加新行时会出现这样的问题
请高手路过解答一下。
而如果通过直接查询数据库,记录行数超过21行就可以显示滚动条,一切都正常,为什么动态添加新行时会出现这样的问题
请高手路过解答一下。
你设置datagridview限高了?看看这样:
dataGridView1.ScrollBars = ScrollBars.Vertical;
this.LV_SP.Activation = System.Windows.Forms.ItemActivation.OneClick;
this.LV_SP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LV_SP.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LV_SP.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LV_SP.FullRowSelect = true;
this.LV_SP.GridLines = true;
this.LV_SP.Location = new System.Drawing.Point(2, 14);
this.LV_SP.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.LV_SP.Name = "LV_SP";
this.LV_SP.Size = new System.Drawing.Size(313, 172);
this.LV_SP.TabIndex = 4;
this.LV_SP.UseCompatibleStateImageBehavior = false;
this.LV_SP.MouseClick += new System.Windows.Forms.MouseEventHandler(this.LV_SP_MouseClick);
this.LV_SP.DoubleClick += new System.EventHandler(this.LV_SP_DoubleClick);