.Net DataGridViews在不同选项卡页中绑定到相同的绑定源
我有一个带有选项卡控件的 winform (C# VS2008 .net 3.5)。 选项卡控件上的两个页面将数据网格视图绑定到同一绑定源。 这很好用。
但是,选项卡页存在一个错误,即选项卡页中保存的数据网格视图始终显示绑定表的第一列,无论它在设计时是否设置为可见。
要解决此问题,您只需手动将 column.visible 属性设置为 false 即可。 当我只有一个 DGV 绑定到 BindingSource 时,这种方法效果很好。 两人被束缚后,一些奇怪的事情发生了。 我手动将两个 DGV 的第一列设置为visible = false,但有时只有一个实际占用,并且该列仍然显示在另一个中。 此外,当单击 DGV 中显示第一列的记录时,会引发以下异常:
InvalidOperationException - 操作 无效,因为它会导致 可重入调用 SetCurrentCellAddressCore 函数。
有其他人经历过这种情况或者对选项卡页的列[0]问题有更好的解决方案吗?
I have a winform (C# VS2008 .net 3.5) with a Tab Control. Two of the pages on the tab control have Data Grid Views bound to the same Binding Source. This works fine.
However, there is a bug with Tab Pages in that Data Grid Views held in Tab Pages always show the first column of the bound table, whether or not it is set to visible at design time.
To work around this, you just set the column.visible property to false manually. This worked fine when I only had a single DGV bound to the BindingSource. With two bound, some strange things happen. I manually set both DGV's first column to visible = false, but sometimes only one actually takes, and the column still shows in the other. Further, when clicking a record in the DGV that is showing the first column, the following exception is raised:
InvalidOperationException - Operation
is not valid because it results in a
reentrant call to the
SetCurrentCellAddressCore function.
Has anyone else experienced this or have a better fix for the column[0] problem with Tab Pages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论