如何在两个不同的选项卡上显示相同的控件? [英] How to display the same control on two different tabs?

查看:101
本文介绍了如何在两个不同的选项卡上显示相同的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.NET

I'm using VB.NET

我需要在两个不同选项卡上显示相同的控件(ListBox)。

I need same control (ListBox) to be displayed on 2 different tabs.

是否必须创建2个不同的ListBox实例?

Is it mandatory to create 2 different ListBox instances?

推荐答案

如果不需要设计时支持您可以在运行时简单地将ListBox实例的Parent从一个选项卡更改为另一个选项卡(当然,请确保正确设置位置)。

If you don't need design-time support you can simply, at runtime, change the ListBox instance's Parent from one tab to the other (making sure to set the positioning appropriately, of course).

本质上,它是:

listBox1.Parent = tabControl1.TabPages [1];

最后,您可能会发现拥有两个具有相同数据源的ListBox会更容易。

In the end though, you'll probably find it easier to just have two ListBox's with the same data source.

这篇关于如何在两个不同的选项卡上显示相同的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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