designating tabpage based on name. "toString" not possible.
I am trying to figure out how to change the tab selected in a tabcontrol and tell the program which tab to select based on its' name. The problem is that the tab would be added programmatically in runtime. The error report says
"Value of type 'String' cannot be converted to 'System.Windows.Forms.TabPage'. "
What can I do?
Code:
Private Sub CatBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CatBtn1.Click
TC2.SelectedTab = Me.Text
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
y = y + 24
Dim NTP As New TabPage()
TC2.Controls.Add(NTP)
NTP.Width = 75
Dim NCB As New CatBtn()
NCB.Location = New Point(0, y)
Panel1.Controls.Add(NCB)
Dim NLV As New ListView()
NLV.Dock = DockStyle.Fill
NLV.Items.Add("item 1")
NLV.Items.Add("item 2")
Label2.Text = y
NTP.Text = TextBox2.Text
NCB.Text = TextBox2.Text
TextBox2.Text = ""
End Sub
BTW, I failed to mention this in my last post. I know I went on a long hiatus. I was designing someone's website with flash cs5.
Re: designating tabpage based on name. "toString" not possible.
You're going to have to loop through all the tabpages inside the Tabcontrol, and then test the name property
Something like :
Code:
For Each tb As TabPage In TabControl1.TabPages
If tb.Name = TextBox1.Text Then
TabControl1.SelectedTab = tb
End If
Next
The names might be case sensitive. This may be an option to you :)
BTW, I took a hiatus a while back - it's incredible how you miss this place when you're gone :lol: :)
Re: designating tabpage based on name. "toString" not possible.
Code:
TC2.SelectedTab = TC2.TabPages(Me.Text)
Re: designating tabpage based on name. "toString" not possible.
Quote:
Originally Posted by
Mur16
Code:
TC2.SelectedTab = TC2.TabPages(Me.Text)
:thumb:
Seems like I was under the influence when I posted. :blush: :p Good job !