I think the dropdownlist defaults to the first item in the order.
If you want nothing to appear, you would have to have a "blank" item as the
first item in the list. You could either add this when you build the
dropdownlist or later when you wanted to reset the appearance:
Private Sub Button2_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button2.Click
If DropDownList1.I tems.IndexOf(Dr opDownList1.Ite ms.FindByValue( "")) = -1
Then
DropDownList1.I tems.Insert(0, "")
End If
DropDownList1.S electedIndex = 0
End Sub
Ken
MVP [ASP.NET]
"Northern" <li******@msn.c om> wrote in message
news:03******** *************** *****@phx.gbl.. .
I guess I didn't phrase my question clearly.
I don't want to remove anything from the list's item
collection. What I want is just to clear the current
selection so that the display box of the dropdownbox on
the form will be blank. But if now I click on the dropdown
again, I can see all items are still there.
Thanks
-----Original Message-----
Is it that you just want to return to the default setting?
DropDownList1.S electedIndex = 0
Or remove the one that is selected and leave the rest?
DropDownList1. Items.RemoveAt( DropDownList1.S electedIndex)
Ken
MVP [ASP.NET]
"Northern" <li******@msn.c om> wrote in message
news:00******* *************** ******@phx.gbl. ..
I need to write code clear the display box of my
DropDownList (something like clear current selected item)
while still keep the loaded item list in the DropDownList.
I tried DropDownList's ClearSelecttion () method and set
SelectedInde x to -1 but neither works.
How should I do this?
Thanks
.