从VB.NET中的另一个标签页添加标签页 [英] Add a tabpage from another tabpage in VB.NET

查看:130
本文介绍了从VB.NET中的另一个标签页添加标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过单击同一表单的另一个标签页中的数据网格视图向tabcontrol添加新标签页。使用休眠代码完成任务但没有收到任何错误或输出。



I am trying to add a new tabpage to a tabcontrol by clicking a data-grid view in another tabpage of the same form. using the fallowing code for the task but not getting any error or output.

Dim TP As New TabPage
TP.Text = "   Payment    . "
form1.TabControlEx1.TabPages.Add(TP)
form1.TabControlEx1.SelectedTab = TP
Dim child As New FastPayment
child.TopLevel = False 
child.FormBorderStyle = Windows.Forms.FormBorderStyle.None
child.Dock = DockStyle.Fill
TP.Controls.Add(child)
child.Show()





我是什么尝试过:





What I have tried:

Dim TP As New TabPage
TP.Text = "   Payment    . "
form1.TabControlEx1.TabPages.Add(TP)
form1.TabControlEx1.SelectedTab = TP
Dim child As New FastPayment
child.TopLevel = False 
child.FormBorderStyle = Windows.Forms.FormBorderStyle.None
child.Dock = DockStyle.Fill
TP.Controls.Add(child)

推荐答案

这与我添加新标签页的代码非常类似:

That's very similar to the code I user to add a new tab page:
TabPage tp;
foreach (User user in justUsers)
    {
    tp = new TabPage(user.LongName);
    tp.DoubleClick += UserTabPage_DoubleClick;
    tp.Tag = user;
    UserDataView view = new UserDataView(user, entries[user]);
    view.Dock = DockStyle.Fill;
    view.ToggleDisplay += view_ToggleDisplay;
    view.TargetValue = Properties.Settings.Default.TargetValue;
    view.TargetChanged += view_TargetChanged;
    tp.Controls.Add(view);
    tabUsers.TabPages.Add(tp);
    }

不可否认,我的是C#,但我们都以相同的顺序做同样的事情。

所以你的代码可能不是导致问题,或者如果是,它被某个地方的一个捕获块吞没。

最有可能的是,代码由于某种原因没有被执行。



在第一行放置一个断点,然后逐步完成代码:确保它们全部被执行并密切关注变量。通过检查现有的TabPages确保它是正确的TabControl。

Admittedly, mine is in C#, but we are both doing the same things in the same order.
So it's probably not your code that is causing a problem, or if it is, it's being "swallowed" by a catch block somewhere.
Most likely, the code isn't being executed for some reason.

Put a breakpoint on the first line, and step your way through the code: make sure that it's all being executed and look closely at the variables as you go. Make sure that is the right TabControl by checking the existing TabPages as well.


这篇关于从VB.NET中的另一个标签页添加标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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