-
Aug 9th, 2014, 02:16 AM
#1
Thread Starter
New Member
[RESOLVED] Reminder - Listbox with item can't select generated tab
Hello, i have problem.
I make program, that is something like reminder
Here is code:
Private Sub save()
Dim t As New TabPage
Dim newt As New Template
Form1.ListBox1.Items.Add(DateTimePicker2.Text & " | " & TextBox1.Text)
newt.Show()
newt.TopLevel = False
newt.Dock = DockStyle.Fill
t.Controls.Add(newt)
t.Name = TextBox1.Text
Form1.TabControl1.TabPages.Add(t)
' And here, if i select added item from list box then tabcontrol select added tab(t)
' I want this for each item. 1 item = 1 generated template.
' ˇˇˇ Here is my idea, but it doesn't work ˇˇˇ
If Form1.ListBox1.SelectedItem = DateTimePicker2.Text & " | " & TextBox1.Text Then
Form1.TabControl1.SelectedTab = t
End If
End Sub
-
Aug 9th, 2014, 02:48 AM
#2
Re: Reminder - Listbox with item can't select generated tab
Not sure I really understand the question, so FWIW, one way might be to use the datetime+textbox for the tabpage Name, then loop & compare to that...
Code:
Dim dtp As String = DateTimePicker2.Text & " | " & TextBox1.Text
Form1.ListBox1.Items.Add(dtp)
newt.Show()
newt.TopLevel = False
newt.Dock = DockStyle.Fill
t.Name = dtp
t.Controls.Add(newt)
Form1.TabControl1.TabPages.Add(t)
Code:
Dim dtp As String = DateTimePicker2.Text & " | " & TextBox1.Text
If Form1.ListBox1.SelectedItem.ToString = dtp Then
For Each t As TabPage In Form1.TabControl1.TabPages
If t.Name = dtp Then
Form1.TabControl1.SelectedTab = t
Exit For
End If
Next
End If
-
Aug 13th, 2014, 06:36 AM
#3
Thread Starter
New Member
Re: Reminder - Listbox with item can't select generated tab
Ok, now if i choose one of these generated item in listbox, so I will not see any card..
I want this, if i choose one of these generated item then tab with same name show.
I tried this, but its crap:
Code:
ListBox1.SelectedItem = TabControl1.SelectedTab.Text
Thank you for answers.
-
Aug 13th, 2014, 08:38 AM
#4
Member
Re: Reminder - Listbox with item can't select generated tab
For that, take Edgemeal second code block, change it a bit and put it in the ListBox's click event.
Code:
Dim selected As String = Form1.ListBox1.SelectedItem.ToString()
For Each t As TabPage In Form1.TabControl1.TabPages
If t.Name = selected Then
Form1.TabControl1.SelectedTab = t
Exit For
End If
Next
-
Aug 13th, 2014, 09:33 AM
#5
Thread Starter
New Member
Re: Reminder - Listbox with item can't select generated tab
It's work, i just had to delete "ToString" from SelectedItem
Code:
Dim selected As String = ListBox1.SelectedItem
For Each t As TabPage In TabControl1.TabPages
If t.Text = selected Then
TabControl1.SelectedTab = t
Exit For
End If
Next
Thank you
-
Aug 13th, 2014, 09:44 AM
#6
Member
Re: Reminder - Listbox with item can't select generated tab
Then please mark this thread as solved in the thread tools. You are welcome.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|