预填充数据网格视图 [英] Pre-Populating a Data Grid View

查看:71
本文介绍了预填充数据网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试预填充网格视图,我可以使第一行填充得很好,但是当我添加另一行时,它添加了一个空行,然后是我想要的行,我该如何摆脱这些多余的东西空行?

这是我的代码.

I am trying to Pre populate a Grid View, I can get the first line to populate just fine but when I add another line, it adds a blank line then the line that I want, how do I get rid of this extra blank line?

Here is my code.

dgImpactTwo.Rows(0).Cells("IZCycles").Value = "SEGMENT 1"
                   dgImpactTwo.Rows(0).Cells("IZPOS").Value = pos
                   dgImpactTwo.Rows(0).Cells("IZNEG").Value = ""
                   min = (pos * 0.2)
                   max = (pos * 0.5)
                   dgImpactTwo.Rows(0).Cells("IZMIN").Value = min
                   dgImpactTwo.Rows(0).Cells("IZMAX").Value = max
                   dgImpactTwo.Rows(0).Cells("IZPassTwo").Value = ""
                   dgImpactTwo.Rows(0).Cells("IZTestTwo").Value = ""
                   dgImpactTwo.Rows(0).Cells("IZNotesTwo").Value = ""
                   dgImpactTwo.Rows(0).Cells("IZIDTwo").Value = ""
                   dgImpactTwo.Rows.Add()
                dgImpactTwo.Rows(0).Cells("IZCycles").Value = "SEGMENT 2"
                   dgImpactTwo.Rows(0).Cells("IZPOS").Value = pos
                   dgImpactTwo.Rows(0).Cells("IZNEG").Value = ""
                   min = (pos * 0)
                   max = (pos * 0.6)
                   dgImpactTwo.Rows(0).Cells("IZMIN").Value = min
                   dgImpactTwo.Rows(0).Cells("IZMAX").Value = max
                   dgImpactTwo.Rows(0).Cells("IZPassTwo").Value = ""
                   dgImpactTwo.Rows(0).Cells("IZTestTwo").Value = ""
                   dgImpactTwo.Rows(0).Cells("IZNotesTwo").Value = ""

推荐答案

尝试以下操作...
Try the following...
Dim row As New DataGridViewRow
row.CreateCells(MyDataGridView)
row.Cells("SomeColumn").Value = "Hello"
row.Cells("SomeOtherColumn").Value = 123
' etc.
MyDataGridView.Rows.Add(row)


实际上, MSDN上的DataGridView上有很多信息 [ ^ ] ...您应该检查一下.


There is actually quite some info on the DataGridView on MSDN[^]... You should check there.


这篇关于预填充数据网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆