用空行填充DataGridview [英] Fill DataGridview with empty rows

查看:96
本文介绍了用空行填充DataGridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我在Windows窗体中有一个datagridview.即根据组合框中的选定值填充数据库中的数据.对于某些选定的项目,在数据库中有记录.对于一些没有记录.那时我需要保持一个固定大小的datagridview,其中没有任何记录(最少10条记录).如果记录数小于10,那么我需要用空行填充它以达到10的计数.有没有办法做到这一点.如果是,请帮助我..我试图将null值行添加到grid-view的数据源中.

Hi...
I have one datagridview in my windows form. That is filling data from database based on selected value in the combo-box. For some selected item there is record in the database. for some there is no records. At that time i need to maintain a fixed size datagridview with no records filled in it(minimum 10 record). if the number of record is less than 10 then i need to fill it with null rows to achieve the count of 10. Is there any way to do this. If yes please help me.. i tried to add null value row to the data-source of grid-view. but it causing some problems while processing the grid-view values.

推荐答案



从数据库中获取数据之后.遍历每个组合选择的数据,如果计数少于10,则添加,然后将更多对象添加到列表中,以达到计数10.
Hi,

After fetching the data from data base. Traverse the data for each combo selection and add if the count is less then 10 add more object into the list to reach count 10.


这篇关于用空行填充DataGridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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