我想在这里做的是,对于添加到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