如何显示具有特定指定的tabcontrol的对话框? [英] how to show dialogue box with a particular specified tabcontrol?

查看:68
本文介绍了如何显示具有特定指定的tabcontrol的对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有许多标签的对话框.我希望它使用特定的tabcontrol打开.我该怎么办?

i have a dialogue box with many tabs. i want it to open with a particular tabcontrol. how can i do it?

推荐答案

使用 ^ ]属性-您可以在Load事件中或在构造函数中进行设置.



是的,我知道我是在说同样的话,但是用的方式不正确.
我想用指定的选项卡打开视图"对话框,而不是当前实例.
如果我将此视图编码为v1 =新视图,那么该视图是否会成为当前实例?"



视图永远不会成为实例-它是类的结构.
如果执行代码:
Use the TabControl.SelectedTab[^] property - you can set it in your Load event, or as part of your constructor.



"yeh i know i m saying the same but not in a proper way.
i wanna open "view" dialogue with a specified tab n its not the current instance.
if i code this view v1 = new view then does view become the current instance?"



view never becomes an instance - it is the structure of the class.
If you execute the code:
view v1 = new view();

然后发生了很多事情:
1)创建一个名为v1的局部变量,该局部变量可以引用view类的项目.
2)创建view的新实例
3)调用view的构造函数,并且this成为对刚刚创建的新实例的引用.每当您在view类中进行编码并使用this显式地使用

Then a number of things happen:
1) A local variable called v1 is created, which can refer to items of the view class.
2) A new instance of a view is created
3) The constructor for view is called, and this becomes a reference to the new instance just created. Whenever you code in the view class and it uses this either explicitly with

this.myProperty = "Hello";

或隐式地使用

myProperty = "Hello";

时,它都引用实例.
4)为vi分配了实例的值,以便您可以在view类之外执行任何操作.

在您的情况下,您可能想按照以下方式进行操作:

it refers to the instance.
4) vi is assigned the value of the instance, for you to do whatever you need to outside the view class.

In your case, you probably want to do something along the lines of:

view v1 = new view();
v1.ActiveTab = "Tab Text";
v1.ShowDialog();

仅需在视图类中编写属性"ActiveTab"即可选择活动选项卡!



确定完成.
我对此进行编码"

Only you will have to write the property "ActiveTab" in your View Class to select the active tab!



"ok its done.
i code this"

View v2 = new View();
v2.Show();
v2.vtab.SelectedTab = v2.vtab.TabPages[1];
v2.vtab.Show();




为了您自己,请不要这样做.而是在View类中设置一个公共int属性,该属性选择该选项卡页面:




Please, for your own sake, don''t do that. Instead set up a public int property in the View class which selects that tab page:

public int SelectPage
   {
   get { return vtab.SelectedIndex; }
   set { vtab.SelectedTab = vtab.TabPages[value]; }
   }

请勿公开表单控件!如果这样做,则将这两种形式结合在一起-如果不考虑对另一种形式的影响,就无法更改一种形式的内部工作方式.这违反了OOP的原则!

Do not make form controls public! If you do, you tie the two forms together - you can''t change how one works internally without considering the effects on the other. This is against the principles of OOP!


这篇关于如何显示具有特定指定的tabcontrol的对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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