C#DataGrid清除问题. [英] C# DataGrid clearance issue.

查看:66
本文介绍了C#DataGrid清除问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想清除我正在使用的DataGrid.

这是我当前正在使用的代码:-

I want to clear the DataGrid that I am using.

This is the code I am currently using:-

DataGrid.DataSource = null;
DataGrid.Rows.Clear();



尽管它在更新记录时会删除标头,但它仅在第一次使用时才起作用.

请有人能建议我要去哪里.



It only works the first time it is used, although it removes the header when the record is updated.

Please can someone suggest where I am going wrong.

推荐答案

仅使用
DataGrid.Rows.Clear();


您应该使用DataGridView控件而不是DataGrid.
DataGridView控件替换并向DataGrid控件添加功能,
并且您的代码可以完美地使用它.
You should use DataGridView control instead of DataGrid.
The DataGridView control replaces and adds functionality to the DataGrid control,
and your code works perfectly with it.


这篇关于C#DataGrid清除问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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