当 dgv 隐藏时,DataGridView 滚动条消失(GUI /刷新问题)

发布于 2024-08-01 20:34:35 字数 323 浏览 4 评论 0原文

我有一个表单应用程序,将多个 DataTable 的结果显示到多个 DataGridView 中,每个 DataGridView 出现在应用程序的不同选项卡中。

当我重新加载数据时,我注意到了奇怪的行为(一个按钮调用从匹配的 DT 中填充所有 DGV):具有大量行(需要垂直滚动)的 DGV 未显示(仅显示一个,因为它们位于选项卡控件)在数据获取后没有滚动条。 但是窗口大小调整会显示滚动条...

我尝试在 dgv.DataSource = dt 之后在每个 DGV 上强制执行 dgv.Refresh() ,但没有运气。

任何意见将不胜感激。

干杯!

I have a forms application, showing results of several DataTables into several DataGridViews, each appearing in a different tab of an application.

I've noticed weird behavior when I reload the data (a single button invokes filling all DGVs from the matching DTs): DGVs with a lot of rows (which require vertical scrolling) which are not shown (only one is shown since they are in a tab control) don't have their scroll bars after the data fetch. But a window resize will show the scroll bars though...

I've tried forcing a dgv.Refresh() on each DGV after the dgv.DataSource = dt, but no luck.

Any input will be appreciated.

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小伙你站住 2024-08-08 20:34:35

也许填充后会这样?

dgv.ScrollBars = ScrollBars.Vertical;

希望它有帮助,如果没有,你能告诉我们你是如何填充它们的吗?

谢谢。

Maybe this after populating it?

dgv.ScrollBars = ScrollBars.Vertical;

Hope it helps, if not, could you show us how you're populating them?

Thanks.

李白 2024-08-08 20:34:35

我的情况听起来和你的差不多。 我遇到了同样的问题,发现这是因为我在后台线程中禁用和启用选项卡。 一旦我将禁用和启用选项卡的调用移至主线程,滚动条就会正常运行。

My situation sounds pretty much identical to yours. I was having this same issue and found out it was because I was disabling and enabling the tabs in a background thread. Once I moved the calls to disable and enable the tabs to the main thread the scrollbars behaved normally.

只怪假的太真实 2024-08-08 20:34:35

我有一个稍微类似的问题,但这可能有助于激发您的想法。 对我来说,这似乎与我的控件的停靠方式有关。 我找到了一个相当复杂的解决方案,简而言之,就是添加一个新面板,然后将控件再次重新放置在该面板的顶部。 由于我发现在所有控件出现后重新调整表单大小会带回滚动条,因此我刚刚添加了 me.width = me.width+1 作为我的 form_load 事件的最后一条语句。

I have a slightly similar issue, but maybe this may help in sparking an idea for you. For me, it appears to be something to do with the way my controls are docked. I found a rather convoluted solution which in short, says to add a new panel, and re-position the controls again on top of that panel. Since i found that re-sizing the form after all my controls appears to bring back the scroll bars, I just added a me.width = me.width+1 as my last statement to my form_load event.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文