vb.net 为 tabcontainer 设置默认活动选项卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17849619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:23:08  来源:igfitidea点击:

Setting default active tab for tabcontainer

c#asp.net.netvb.netvisual-studio-2008

提问by C Sharper

I am using tabcontainer in my project having two tabs as English and Spanish.

我在我的项目中使用 tabcontainer 有两个选项卡,分别是英语和西班牙语。

Tabs are as follows:

选项卡如下:

enter image description here

在此处输入图片说明

As we can see in pic, default active tab set is spanish.

正如我们在图片中看到的,默认的活动标签集是西班牙语。

I wanted it to be English.

我希望它是英文的。

For that i made following code:

为此,我制作了以下代码:

tcQuestion.ActiveTabIndex = "1"this i written on pageload, as well ,

tcQuestion.ActiveTabIndex = "1"这也是我在页面加载上写的,

in aspx: <asp:TabContainer ID="tcQuestion" runat="server" ActiveTabIndex="1" Width="90%">i added ActiveTabIndex="1"

在 aspx 中: <asp:TabContainer ID="tcQuestion" runat="server" ActiveTabIndex="1" Width="90%">我添加了ActiveTabIndex="1"

But as we can see in pic, no difference with this code. Default selection is spanish only.

但正如我们在图片中看到的,这段代码没有区别。默认选择仅为西班牙语。

For more clarity i would like to share whole code for tab container:

为了更清楚,我想分享选项卡容器的整个代码:

<asp:TabContainer ID="tcQuestion" runat="server" ActiveTabIndex="1" Width="90%"  >
        <asp:TabPanel runat="server" HeaderText="English" ID="English" >
            <ContentTemplate>
                <table align="center"  width="90%">
                    <tr>
                        <td align="center" class="Heading" colspan="2" valign="top" >
                         <asp:Label ID="lblEnglish"  Text="Add Question" runat="server" ></asp:Label>
                        </td>
                    </tr>
                    <tr>
                      <td align="right" class="NormalText" width="40%" valign="top" >
                             Question :
                         </td>
                        <td align="left">
                            <asp:TextBox ID="txtEnglishQuestion" runat="server" CssClass="ThinTextBox" Rows="7" Columns="35"  
                                TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>

                </table>
            </ContentTemplate>


        </asp:TabPanel>
         <asp:TabPanel ID="TabPanel2" runat="server" HeaderText="Spanish" >
             <ContentTemplate>
                 <table align="center"  width="90%">
                     <tr>
                         <td align="center" class="Heading" colspan="2" valign="top"  >
                             Add Question
                         </td>
                     </tr>
                     <tr>
                         <td align="right" class="NormalText" width="40%" valign="top" >
                             Question :
                         </td>
                         <td align="left">
                             <asp:TextBox ID="txtQuestionSpanish" runat="server" CssClass="ThinTextBox" Rows="7" Columns="35"  
                                 TextMode="MultiLine"></asp:TextBox>
                         </td>
                     </tr>


                 </table>
             </ContentTemplate>
         </asp:TabPanel>

    </asp:TabContainer>

note : Programming language does not matters to me (wheather its c# or vb.net)

注意:编程语言对我来说并不重要(无论是 c# 还是 vb.net)

Please help me.

请帮我。

回答by Sain Pradeep

You need to set tab index to zero (0).

您需要将选项卡索引设置为零 (0)。

tcQuestion.ActiveTabIndex = 0

回答by Sain Pradeep

tcQuestion.ActiveTabIndex = 0

you had given index of 2nd tab. But the index should be 0 for first tab

你已经给出了第二个标签的索引。但是第一个标签的索引应该是 0