Click here to Skip to main content
15,909,539 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionXML Manipulation Pin
JC.KaNNaN6-Oct-10 19:59
JC.KaNNaN6-Oct-10 19:59 
AnswerRe: XML Manipulation Pin
Bhim Prakash Singh6-Oct-10 22:34
Bhim Prakash Singh6-Oct-10 22:34 
AnswerRe: XML Manipulation Pin
Richard MacCutchan6-Oct-10 22:35
mveRichard MacCutchan6-Oct-10 22:35 
QuestionCustom Maps for GPS Pin
Dominick Marciano6-Oct-10 17:58
professionalDominick Marciano6-Oct-10 17:58 
AnswerRe: Custom Maps for GPS Pin
Dave Kreskowiak7-Oct-10 2:21
mveDave Kreskowiak7-Oct-10 2:21 
QuestionSecurity Pin
hang_em4-Oct-10 18:35
hang_em4-Oct-10 18:35 
AnswerRe: Security Pin
Eduard Keilholz4-Oct-10 19:54
Eduard Keilholz4-Oct-10 19:54 
Question[VB10] TabControl or TabPage or ListView bug? Pin
The Mighty Atom4-Oct-10 4:22
The Mighty Atom4-Oct-10 4:22 
Im having an annoying little bug or glitch when i try to get data from a listview on the seconds tabpage of a tabcontrol.

Here's how you can replicate the issue, so follow these steps:

1. Create a Windows Forms application, using any Framework.
2. Place a tabcontrol. It comes with two tabs by default. Go into the second tab.
3. Place a listview on the second tabpage, add one collumn to the listview and set the HideSelection property to False.
4. Place a button on the form.
5. Put the following code in the Form_Load sub:

For i = 1 To 10
    ListView1.Items.Add(i)
Next

Dim Rand As New Random
Dim int As Integer

For Each lvi As ListViewItem In ListView1.Items
    int = Rand.Next(0, 2)
    If int = 0 Then
        lvi.Selected = False
    Else
        lvi.Selected = True
    End If
Next


This will fill the listview with numbers 1 to 10. Then, it will randomly select/highlight some of those numbers.

6. Put the following code in the button's click event:

For Each SelLvi As ListViewItem In ListView1.SelectedItems
    MessageBox.Show(SelLvi.Text)
Next


This will display all the selected/highlighted numbers in the listview in a messagebox.

7. Debug the program. We know that the listview had been filled with numbers 1 to 10 during form load, and that some of those are selected/highlighted. Now click the button. Nothing happens. No messagebox.

8. Click on the second tabpage. You can see that the listview contains items. Go back to the first tabpage, and click the button again. Now a messagebox pops up containing the selected/highlighted numbers.

See what the problem is? It seems you can only get the listview items once you've seen the contents of the second tabpage at least once. If you don't visit the second tabpage after starting the application, it won't work, you won't get a messagebox even though we know the listview has items and that some of those are selected/highlighted.

Anyone know a fix for this? In short: I need to get the selected/highlighted items from the listview on the second tabpage without having to visit/view the contents of the second tabpage first.
Virtual Space Shuttle Astronaut

AnswerRe: [VB10] TabControl or TabPage or ListView bug? Pin
Luc Pattyn4-Oct-10 4:50
sitebuilderLuc Pattyn4-Oct-10 4:50 
GeneralRe: [VB10] TabControl or TabPage or ListView bug? Pin
The Mighty Atom4-Oct-10 5:16
The Mighty Atom4-Oct-10 5:16 
GeneralRe: [VB10] TabControl or TabPage or ListView bug? Pin
Luc Pattyn4-Oct-10 5:19
sitebuilderLuc Pattyn4-Oct-10 5:19 
GeneralRe: [VB10] TabControl or TabPage or ListView bug? [modified] Pin
The Mighty Atom4-Oct-10 5:31
The Mighty Atom4-Oct-10 5:31 
QuestionMy.Settings Pin
Herboren1-Oct-10 23:08
Herboren1-Oct-10 23:08 
AnswerRe: My.Settings Pin
Richard MacCutchan1-Oct-10 23:17
mveRichard MacCutchan1-Oct-10 23:17 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 4:38
Herboren2-Oct-10 4:38 
AnswerRe: My.Settings Pin
Dave Kreskowiak2-Oct-10 4:38
mveDave Kreskowiak2-Oct-10 4:38 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 5:00
Herboren2-Oct-10 5:00 
AnswerRe: My.Settings Pin
Luc Pattyn2-Oct-10 5:38
sitebuilderLuc Pattyn2-Oct-10 5:38 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 5:44
Herboren2-Oct-10 5:44 
JokeRe: My.Settings Pin
DaveAuld2-Oct-10 5:57
professionalDaveAuld2-Oct-10 5:57 
GeneralRe: My.Settings Pin
Herboren2-Oct-10 7:34
Herboren2-Oct-10 7:34 
AnswerRe: My.Settings Pin
DaveAuld2-Oct-10 5:54
professionalDaveAuld2-Oct-10 5:54 
GeneralRe: My.Settings Pin
Herboren3-Oct-10 5:06
Herboren3-Oct-10 5:06 
GeneralRe: My.Settings Pin
DaveAuld3-Oct-10 8:10
professionalDaveAuld3-Oct-10 8:10 
QuestionGregorian date to convert solar (Tarikh Shamsi) Pin
saywan161-Oct-10 2:18
saywan161-Oct-10 2:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.