您是否必须在所有文本框实际填充之前显示每个选项卡? [英] Do you have to show every tab before all textboxes actually populate?

查看:43
本文介绍了您是否必须在所有文本框实际填充之前显示每个选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 vb.net 表单,它在几个不同的选项卡上使用多个文本框.在其中一个选项卡中,我有一组选项卡.我的保存功能调用每个选项卡的存储过程,并循环浏览每个页面上的值以进行更新或添加新的".我注意到在测试时,某些页面不会保存或更新文本框中的任何值.经过几天的调查,我意识到如果我编辑一些东西,然后物理点击其他选项卡,它都会正确保存/更新.如果我不点击它们,它们就不会全部保存.我失踪有什么原因吗?当您输入搜索值时,我会循环浏览页面并同时填充它们,因此我假设它在物理呈现之前写入了这些值......我想我错了吗?

I have a vb.net form that uses multiple textboxes across several different tabs. Within one of those tabs, I have a sub set of tabs. My save functionality calls stored procs for each tab and cycles through the values on each page to either do an update or a "add new". I noticed that while testing, some of the pages do not save or update any of the values in the textboxes. After a few days of investigating, I realized that if I edit something, then physically click through the other tabs, it all saves/updates properly. If I don't click through them, they don't all save. Is there a reason for this that I am missing? When you enter a search value, I cycle through the pages and populate them all at the same time so I was assuming it wrote those values BEFORE it physically rendered...I guess I am wrong?

推荐答案

来自 TabPage 文档备注部分

在显示选项卡页之前不会创建包含在 TabPage 中的控件,并且在显示选项卡页之前不会激活这些控件中的任何数据绑定.

Controls contained in a TabPage are not created until the tab page is shown, and any data bindings in these controls are not activated until the tab page is shown.

因此,您的问题的答案是是的,必须显示标签页".

So the answer to your question is "Yes the tabpage must be shown".

然而,显示"的定义有待解释.实际上,您只需将 TabPage.Visible 属性设置为 True,而不是实际循环显示每个 TabPage.

However, the definition of "shown" is subject to interpretation. In reality, all you need to do set the TabPage.Visible property to True and not actually cycle through and display each TabPage.

TabPage 控件的表单进行递归扫描即可:

A recursive scan of the form for TabPage controls will work:

Private Shared Sub TabPagesVisible(parent As Control)
    For Each c As Control In parent.Controls
        If TypeOf c Is TabPage Then c.Visible = True
        TabPagesVisible(c)
    Next
End Sub

示例用法:

Sub SaveFormTabData()
    TabPagesVisible(Me) ' Me refers to the containing form
    ' code to save control data
End Sub

这篇关于您是否必须在所有文本框实际填充之前显示每个选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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