DataGridView.Clear()

前端 未结 19 1828
夕颜
夕颜 2020-12-02 20:01

Here comes the trouble. I want to delete all rows from datagridview. This how i add rows:

private void ReadCompleteCallback(object clientHandle, Opc.Da.ItemV         


        
相关标签:
19条回答
  • 2020-12-02 20:17

    try:

    datagrid.DataSource = null;
    datagrid.DataBind();
    

    Basically you will need to clear the datasource your binding to the grid.

    0 讨论(0)
  • 2020-12-02 20:18

    Try this Method

    dataGridView1.DataSource = dt;
    dt.Rows.Clear();
    
    0 讨论(0)
  • 2020-12-02 20:21

    This is one way of doing it:

    datagridview.DataSource = null;
    datagridview.Refresh();
    

    I hope it works for you because it is working for me.

    0 讨论(0)
  • 2020-12-02 20:22

    Set the datasource property to an empty string then call the Clear method.

    0 讨论(0)
  • 2020-12-02 20:24

    To clear the datagridview write the following code:

    dataGridView1.DataSource=null;
    
    0 讨论(0)
  • 2020-12-02 20:24

    I know it sounds crazy, but I solved this issue by changing the datagrid.visible property to false and then to true. It causes a very small blink, but it works for me (at least for now).

    0 讨论(0)
提交回复
热议问题