5 Replies - 2872 Views - Last Post: 01 December 2012 - 12:04 PM Rate Topic: -----

#1 RoyLittle0   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-November 12

programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 07:45 AM

Can anyone explain how to change the text in a TabControl, i have tried to use the sane tactics i would with a ListView but cant seem to get it right

The name is being read from an xml file based on the selection made from the ComboBox, and from there it will display the contents of the xml in 3 textBoxes and 3 PictureBoxes

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim NodeCount As Integer


        For Each mySet As XmlNode In myXMLDoc.GetElementsByTagName("Machine")
            If mySet.Attributes.ItemOf("Type").InnerText = ComboBox1.SelectedItem.ToString Then


                For Each myMachineName As XmlNode In mySet.SelectNodes("Page")
                    NodeCount += 1
                    Dim TCI As New TabControl
                    With TCI
                        .Text = NodeCount.ToString
                        .SubItems.Add(myMachineName.InnerText)
                    End With
                    TabControl1.Items.Add(TCI)
                Next


            End If
        Next
    End Sub



There are 10 machines in total, each having 20 pages and the Text and PictureBoxes will display the data based on teh selection, ie, Machine Type (ComboBox), Page Number (TabControl)
<Root>
    <Machine Type="A Machine">
        <Page Number="Page 1, Machine A">
            <Title>1</Title>
            <TextBox>2</TextBox>
            <TextBox>3</TextBox>
            <TextBox>4</TextBox>        
            <PictureBox>5</PictureBox>
            <PictureBox>6</PictureBox>
            <PictureBox>7</PictureBox>
            <Link>8</Link>
        </Page>
        <Page Number="Page 2, Machine A">
            <Title>9</Title>
            <TextBox>10</TextBox>
            <TextBox>11</TextBox>
            <TextBox>12</TextBox>        
            <PictureBox>13</PictureBox>
            <PictureBox>14</PictureBox>
            <PictureBox>15</PictureBox>
            <Link>16</Link>        
        </Page>
        <Page Number="Page 3, Machine A">
            <Title>17</Title>
            <TextBox>18</TextBox>
            <TextBox>19</TextBox>
            <TextBox>20</TextBox>        
            <PictureBox>21</PictureBox>
            <PictureBox>22</PictureBox>
            <PictureBox>23</PictureBox>
            <Link>24</Link>        
        </Page>
    </Machine>
</Root>



Is This A Good Question/Topic? 0
  • +

Replies To: programmatically add name to TabControl based on ComboBox selection

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 08:30 AM

Quote

an anyone explain how to change the text in a TabControl


A TabControl is just a container housing TabPages. So I'm not sure what text in the TabControl you're talking about. You probably want to be changing the text of a specific TabPage.

This is all pretty well documented on the MSDN page for TabControl
Was This Post Helpful? 0
  • +
  • -

#3 lar3ry   User is offline

  • Coding Geezer
  • member icon

Reputation: 314
  • View blog
  • Posts: 1,296
  • Joined: 12-September 12

Re: programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 08:38 AM

    TabControl1.TabPages(index).Text = <whatever>


Was This Post Helpful? 1
  • +
  • -

#4 RoyLittle0   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-November 12

Re: programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 08:38 AM

View PosttlhIn`toq, on 01 December 2012 - 08:30 AM, said:

Quote

an anyone explain how to change the text in a TabControl


A TabControl is just a container housing TabPages. So I'm not sure what text in the TabControl you're talking about. You probably want to be changing the text of a specific TabPage.

This is all pretty well documented on the MSDN page for TabControl


Yes the TabPages within the TabControl, i want to change all Pages within the TabControl, not through the properties but through the program, i have looked through the NSDN sit with little success, it only explains how to change them through the properties
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 10:31 AM

Well everything is changed through properties even when you do it programmatically. So I'm at a loss as to where you are actually confused.

When you say you don't want to do it through "properties" are you saying you don't want to do it in the designer; in the Properties pallet?

You would still set the .Text property for the TabPage even in C# code.

lar3ry was right when he posted this:

TabControl1.TabPages(index).Text = <whatever>
Was This Post Helpful? 0
  • +
  • -

#6 RoyLittle0   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 13-November 12

Re: programmatically add name to TabControl based on ComboBox selection

Posted 01 December 2012 - 12:04 PM

View PosttlhIn`toq, on 01 December 2012 - 10:31 AM, said:

Well everything is changed through properties even when you do it programmatically. So I'm at a loss as to where you are actually confused.


There is no confusion, if you look at the two posts they were posted at the same time, so i didn't have the answer whilst i was typing my second post, Many thanks to Lar3ry for his answer.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1