如何在Datagridview的特定单元格中添加

时间:2016-09-13 07:43:48

标签: c# vb.net datagridview

顺便说一下,我正在使用Datagridview并且我在添加/传递到特定单元格的部分堆叠:                   在我的第0栏:col_a,                   第1栏:col_b,           第2栏:col_c,           第3栏:col_d

这是我的代码:

     '//pass this to  column b
     Dim fcol As String = txtorder.Text
     '//pass this to  column c
     Dim scol As String = txtQuant.Text

     Dim row As String ()= New String (){fcol,scol}
     DatagridView1.Rows.Add(row)

1 个答案:

答案 0 :(得分:0)

顺便说一下这就是答案:我上网了,也是像我这样的初学者,希望它有所帮助:

Dim fcol As String = txtOrder.Text
Dim scol As String = txtQuant.Text

Dim newcol As Integer = Datagridview1.Rows.Add()
Datagridview1.Rows.Item(n).Cells(2).Value = New string() {fcol}
Datagridview1.Rows.Item(n).Cells(3).Value = New string() {scol}