我想在這裏做的是,對於添加到ComboBox
中的每個新項目,Label的文本屬性將顯示前一個數字的+1。如何在更改ComboBox控件的SelectedIndex屬性時更新Label的文本?
我該如何寫出來,假設我沒有將項目分配給一個數字。我的ComboBox
被綁定到一個數據源。
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim studentcheck = StudentTableAdapter.checkstudent(StudentNameTextBox.Text, StudentAddressTextBox.Text)
If StudentNameTextBox.Text.Length = 0 Then
MsgBox("Name is Empty")
ElseIf StudentAddressTextBox.Text.Length = 0 Then
MsgBox("Address is empty")
ElseIf studentcheck Is Nothing Then
Me.Validate()
Me.StudentBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LibraryDataSet)
frmAddLoan.DisplayLoanTableAdapter.Fill(frmAddLoan.LibraryDataSet.DisplayLoan)
frmAddLoan.ComboBox1.Update()
MsgBox("Student Info Added")
Else
MsgBox("Student Name and Address have been used.")
End If
End Sub
想添加新項目時顯示組合框的總項目數嗎?請提供您的代碼,將新項添加到組合框中,請.. – 2012-02-13 09:02:29
我已經在代碼中添加了關於 – CompleteNewb 2012-02-13 09:13:20
問題的代碼還是要將編號添加到組合框本身?但這取決於項目的排序順序(或指示創建時間或PK列的日期時間列)。 http://stackoverflow.com/a/2023338/284240 – 2012-02-13 09:22:10