C# DataGridView 检查是否为空

编程入门 行业动态 更新时间:2024-10-26 08:27:13
本文介绍了C# DataGridView 检查是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 datagridview,它填充了从 linq 查询返回的数据.如果查询没有返回结果,我想显示一个消息框.有没有办法检查datagridview是否为空?

I have a datagridview which gets filled with data returned from a linq query. If the query returns no results I want to display a messagebox. Is there a way of checking to see if the datagridview is empty?

问候

推荐答案

可以通过查看DataGridView中的行数来判断是否为空.如果 myDataGridView.Rows.Count == 0 那么你的 DataGridView 是空的.

You can find out if it is empty by checking the number of rows in the DataGridView. If myDataGridView.Rows.Count == 0 then your DataGridView is empty.

这篇关于C# DataGridView 检查是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-29 10:29:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/753659.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   DataGridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!