Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MultiSelect ListBox MDI Child

Status
Not open for further replies.

kafmil

Technical User
Jul 15, 2002
71
AU
I have a multi select list box on a form which is a child of an MDI form. I fill the list box with the following code

While objDataReader.Read()
objFuel = New FuelItem(objDataReader("lFuel_ID"), objDataReader("sFuel_Name"))
arrFuel.Add(objFuel)
lstFuel.Items.Add(arrFuel)
blnOK = False
End While
lstFuel.DataSource = arrFuel
lstFuel.DisplayMember = "getFuelName"
lstFuel.ValueMember = "getFuelID"

SourcesFuels is a class which I have created. The list box fills fine and then I try to set multiple selected items in the code like this.

While objDataReader.Read()
lstFuel.SetSelected(lstFuel.FindString(objDataReader("sFuel_Name")), True)
intCount = intCount + 1
End While

The items are selected as they should be.
The Problem occurs when i call the form from the mdi form by pressing a menu button.

If IsNothing(gfrmSources) Then
gfrmSources = New frmFuelSources
ElseIf gfrmSources.IsDisposed Then
gfrmSources = New frmFuelSources
End If

gfrmSources.MdiParent = Me
gfrmSources.Show()

The child form is called, goes through it's functions perfectly, then finishes off the code in the mdi form, which is the end of a select statement ie -

End Select

When the child form displays there is only ever one item selected. The list box seems to drop it's second selected item when the mdi parent finishes off it's code. I think this might be a bug in VB.NET, does anyone have any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top