Dayana Boni Posted July 26, 2011 Report Share Posted July 26, 2011 Pessoal,Só uma dúvida besta (menos pra mim que não sei):Como que faço um For Each para uma DropDownList (em VB.NET), já que do modo abaixo que fiz não dá certo?For Each i As ListItem In DropDownList...Next i Quote Link to comment Share on other sites More sharing options...
0 Xistyle Posted July 26, 2011 Report Share Posted July 26, 2011 DropDownList = ComboBox?For Each item As Object In ComboBox.Items resultado = item.ToString()Next item Quote Link to comment Share on other sites More sharing options...
0 Dayana Boni Posted July 26, 2011 Author Report Share Posted July 26, 2011 Pra mim ComboBox é diferente de DropDownList.Fiz o que você falou mas, no For Each não há a propriedade "Items" para o DropDownList. :mellow: Quote Link to comment Share on other sites More sharing options...
0 Xistyle Posted July 26, 2011 Report Share Posted July 26, 2011 Desculpe, testei um aplicativo desktop:For Each item As Object In DropDownList1.Items MsgBox(item.ToString(), MsgBoxStyle.Information, "TESTE") NextColoquei 3 itens nesse dropdownlist e apareceram 3 messages box pra mim, com os conteúdos :) Quote Link to comment Share on other sites More sharing options...
0 Dayana Boni Posted July 26, 2011 Author Report Share Posted July 26, 2011 XistyleMuito obrigada =)Pra CheckBoxList segue a mesma regra?No caso, para cada item selecionado.... Quote Link to comment Share on other sites More sharing options...
0 Xistyle Posted July 26, 2011 Report Share Posted July 26, 2011 Sim, mesma idéia, só muda a sintaxe:Dim txt As String = " Estudantes selecionados:" & vbCrLf For Each item As Object In chkEstudantes.CheckedItems txt &= item.ToString & vbCrLf Next item MessageBox.Show(txt) Quote Link to comment Share on other sites More sharing options...
0 Dayana Boni Posted July 29, 2011 Author Report Share Posted July 29, 2011 OK!Obrigada ^^ Quote Link to comment Share on other sites More sharing options...
0 Dayana Boni Posted August 8, 2011 Author Report Share Posted August 8, 2011 Só acrescentando, pra mim, o For Each para CheckBoxList funcionou assim: For Each Item As ListItem In CheckBoxList .Items ... Next Quote Link to comment Share on other sites More sharing options...
Question
Dayana Boni
Pessoal,
Só uma dúvida besta (menos pra mim que não sei):
Como que faço um For Each para uma DropDownList (em VB.NET), já que do modo abaixo que fiz não dá certo?
For Each i As ListItem In DropDownList
.
.
.
Next i
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.