0

I have a bindinglist. i am using a textbox to show its items

WithEvents xBind As New BindingList(Of Emp)

I added items this way

xBind.Add(New emp("alpha0", "B"))
xBind.Add(New emp("alpha1", "B"))
xBind.Add(New emp("alpha2", "B"))
xBind.Add(New emp("alpha3", "B"))

I am binding the first property to a textbox

TextBox1.DataBindings.Add("text", xBind, "eName")

It shows "alpha0" in the form which is first item in the xbind Now how do I display the second item in textbox1 when i click "MoveNext" button ?

4

2 回答 2

2

我在寻求类似问题的解决方案时偶然发现了这一点。对于可能遇到此问题的任何其他人,我的解决方案是使用 BindingSource。

Dim bsXBind As New BindingSource
...
bsXBind.DataSource = xBind
TextBox1.DataBindings.Add("Text", bsXBind, "eName")

要移动到另一条记录,请更改 BindingSource.Position:

Private Sub NextXRecord()
    If bsXBind.Position < bsXBind.Count - 1 Then
        bsXBind.Position += 1
    End If
End Sub
于 2012-12-04T15:49:46.110 回答
0

I think you need a listbox or grid instead of a textbox, which only shows one value at a time.

于 2010-09-09T20:24:27.010 回答