0
好吧,我有我的選擇在我的組合框中使我的列表框中的不同列表。我現在想做的事情是讓我的選擇在我的列表框中給我一個變量,以便我可以使用變量計算其他東西(如何我可以如果SeleceIndex = 0那麼)我嘗試了各種嘗試避免寫更多的私人潛艇並運行它們。列表框中的多個變量
我正在使用VB.net 2010和一些奇怪的原因SelectedItem不給我一個數字。我是否應該期望使用不同的短語來查找用戶選擇的列表框中的哪個變量,以及我將不得不將其吸收並使其成爲私人子目錄? (即它看起來像這樣,但這只是一個變體)。
intticket = cbx1.SelectedIndex
inttickets = lstbx1.SelectedItem
If intticket = 0 Then
SeasonSeats()
ElseIf intticket = 1 Then
SingleGameSeats()
End If
If (intticket = 0) AndAlso (inttickets = 0) Then
intseatgame = intseaboxseats
ElseIf (intticket = 0) AndAlso (inttickets = 1) Then
intseatgame = intsealowerdeck
End If
這asp.net或的WinForms? – MatthewMartin 2013-04-23 01:27:55
另外,.SelectedItem可能會返回一個具有Text和Value屬性的對象。參考http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.selecteditem.aspx你可能想選擇更多的心理距離而不是intticket和inttickets的心理距離,除非你打算後者是複數並表示集合等。 – MatthewMartin 2013-04-23 01:31:30
對於WinForm,據我所知,SelectedItem只會返回一些東西,如果你綁定它與數據源.. – Ruly 2013-04-23 01:35:21