如何设置“插入新行"作为 DataGridView 中的第一行 [英] How to set the "insert new row" as first row in DataGridView

查看:42
本文介绍了如何设置“插入新行"作为 DataGridView 中的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 DataGridView 将插入新行"行呈现为网格中的第一行而不是最后一行.我该怎么做,甚至可以在控件中使用吗?

I am trying to get the DataGridView to render the "insert new row" row as the first row in the grid instead of the last row. How do I go about doing that, is it even possible in the control?

推荐答案

我认为没有任何方法可以将新行"行移动到数据网格的顶部.

I don't think there is any way to move the "new row" row to the top of the data grid.

但是,如果您将第一行留空并且随着数据的填充将行适当地向下移动会怎样?换句话说,创建您自己的新行"行,它只是网格中的第一行,并在编辑结束时在上方添加新的空白行.

But, what if you left the top row empty and as the data filled in move the row down as appropriate? In other words, make your own "new row" row, which is just first row in the grid and add new blank rows above when editing is over.

   Dim myrow = existingDataTable.NewRow

    existingDataTable.Rows.Add(myrow)

    adp.Fill(existingDataTable)
    With DataGridView1
        .DataSource =existingDataTable
    End With    

这篇关于如何设置“插入新行"作为 DataGridView 中的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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