第一列未隐藏在datagridview中 [英] First Column not hiding in datagridview

查看:93
本文介绍了第一列未隐藏在datagridview中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagridview,一旦用数据源填充视图,就隐藏了不需要的列。由于某些原因,第一列没有隐藏。我检查了列名,它们匹配并且第二行执行起来很好地隐藏了EVENTID的列。我什至做了一个messagebox.show(dgvTourOther.Columns( OTHERID)。name),它返回了正确的名称。

I have a datagridview and once I populate the view with the data source I hide the columns that I do not need. For some reason the 1st column is not hiding. I have checked the column name and they match and the 2nd line executes fine hides the column for the EVENTID. I even did a messagebox.show( dgvTourOther.Columns("OTHERID").name) and it returned the correct name.

dgvTourOther.Columns("OTHERID").Visible = False
dgvTourOther.Columns("EVENTID").Visible = False

任何想法会导致datagridview不隐藏列吗?就像其他属性锁定该列一样。

Any idea what could cause a datagridview not to hide a column? It is like some other property is locking that column..

要传递的值都是字符串。我在其他3个datagridviews上执行此操作,但是出于某种原因,这个gridview的行为有所不同。我将尝试重新排列列,看看是否有帮助。

The values being passed are all strings. I do this on 3 other datagridviews ok but for somereason this gridview is acting different. I am going to try an rearrange the columns and see if that helps.

推荐答案

我记得在一个项目中有几个问题几年前。我记得有两种潜在的解决方案。第一个是将.Visible设置代码移出构造函数(假设您现在就在那儿),并移到诸如Form_Load事件之类的地方。

I remember having this issue on a project a couple years ago. There were two potential solutions as I recall. The first was moving the .Visible setting code out of the Constructor (assuming thats where you have it now) and into something like the Form_Load event.

第二个解决方案(可能对我真正起作用)是将我想隐藏的列移到网格的末端(右侧)。我知道这很愚蠢。

The second solution (which may have been what really worked for me) was to move the columns I wanted to hide to the end (right side) of the grid. Stupid I know.

这篇关于第一列未隐藏在datagridview中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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