473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

bindinglist not synching

VS 2005

I have a class of BindingList(of T) to use as a datasource for a lookup
combobox. The combobox is to lookup the Terms for a Purchase Order.

When I implement this on my Winform, the combobox does not synch with the
underlying data, i.e. the Terms description does not show for the terms
number.

The combobox does show the Descriptions in the drop-down box, so they are
being filled into the binding list, they just don't synch with the
underlying data.

Can anyone see what is wrong?

Rick

**** combox box is connected like this ***
cbTerms.DisplayMember = "Name"

cbTerms.ValueMember = "Num"

Dim bs As LookupNVP = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)

cbTerms.DataSource = bs

cbTerms.DataBindings.Clear()

cbTerms.DataBindings.Add("SelectedValue", PObind, "Termsnum")
**** class for bindinglist ****

Public Class LookupNVP

Inherits BindingList(Of nvp)

Public Enum listType

Terms

Shipvia

End Enum

Public Class nvp

Private _name As String

Private _num As Integer

Public ReadOnly Property Name() As String

Get

Return _name

End Get

End Property

Public ReadOnly Property Num() As Integer

Get

Return _num

End Get

End Property

Private Sub New()

End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)

_name = newName

_num = newValue

End Sub

End Class

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)

MyBase.New()

Dim sql As String

Select Case list

Case listType.Shipvia

sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM || ']' " _

& "from SHIPVIA order by METHOD"

Case listType.Terms

sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM || ']' " _

& "from TERMS order by DESCRIPTION"

End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

'Dim reader As FbDataReader

Try

conn.Open()

Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)

While reader.Read

Me.Add(New nvp(reader.GetInt32(0), reader.GetString(1)))

End While

reader.Close()

End Using

Finally

conn.Close()

End Try

End Sub

End Class

Mar 31 '07 #1
10 1618
Override the ToString method in your LookupNVP class.

By the way, when you post your code, if you paste it into Notepad, then
copy and paste it into your posting, it will retain its spacing, and be
easier to read. The easier it is to read, the more likely someone will help
you.

Robin S.
---------------------------

"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
VS 2005

I have a class of BindingList(of T) to use as a datasource for a lookup
combobox. The combobox is to lookup the Terms for a Purchase Order.

When I implement this on my Winform, the combobox does not synch with the
underlying data, i.e. the Terms description does not show for the terms
number.

The combobox does show the Descriptions in the drop-down box, so they are
being filled into the binding list, they just don't synch with the
underlying data.

Can anyone see what is wrong?

Rick

**** combox box is connected like this ***
cbTerms.DisplayMember = "Name"

cbTerms.ValueMember = "Num"

Dim bs As LookupNVP = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)

cbTerms.DataSource = bs

cbTerms.DataBindings.Clear()

cbTerms.DataBindings.Add("SelectedValue", PObind, "Termsnum")
**** class for bindinglist ****

Public Class LookupNVP

Inherits BindingList(Of nvp)

Public Enum listType

Terms

Shipvia

End Enum

Public Class nvp

Private _name As String

Private _num As Integer

Public ReadOnly Property Name() As String

Get

Return _name

End Get

End Property

Public ReadOnly Property Num() As Integer

Get

Return _num

End Get

End Property

Private Sub New()

End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)

_name = newName

_num = newValue

End Sub

End Class

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)

MyBase.New()

Dim sql As String

Select Case list

Case listType.Shipvia

sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM || ']' " _

& "from SHIPVIA order by METHOD"

Case listType.Terms

sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM || ']' " _

& "from TERMS order by DESCRIPTION"

End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

'Dim reader As FbDataReader

Try

conn.Open()

Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)

While reader.Read

Me.Add(New nvp(reader.GetInt32(0), reader.GetString(1)))

End While

reader.Close()

End Using

Finally

conn.Close()

End Try

End Sub

End Class

Apr 1 '07 #2
Thanks for the notebook tip.

I overrode the ToString method, but still no joy. The addition is ********
below.

What did I do wrong?

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Class nvp
Private _name As String
Private _num As Integer

Public ReadOnly Property Name() As String
Get
Return _name
End Get
End Property
Public ReadOnly Property Num() As Integer
Get
Return _num
End Get
End Property

Private Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

'********************************************
Public Overrides Function ToString() As String
Return Me.Name
End Function

'*********************************************

End Class

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM ||
']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM ||
']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)
'Dim reader As FbDataReader
Try
conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read
Me.Add(New nvp(reader.GetInt32(0), reader.GetString(1)))
End While
reader.Close()
End Using

Finally
conn.Close()
End Try

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:6f******************************@comcast.com. ..
Override the ToString method in your LookupNVP class.

By the way, when you post your code, if you paste it into Notepad, then
copy and paste it into your posting, it will retain its spacing, and be
easier to read. The easier it is to read, the more likely someone will
help you.

Robin S.

Apr 1 '07 #3
Move your nvp class out of your lookupNvp class.

Public Class LookupNVP
Inherits BindingList(of nvp)
....
End Class

Public Class NVP
....
(ToString goes here)
End Class

Put the reading of the database in LookupNVP, and add each NVP object to
your list.

Robin S.
---------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl...
Thanks for the notebook tip.

I overrode the ToString method, but still no joy. The addition is
******** below.

What did I do wrong?

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Class nvp
Private _name As String
Private _num As Integer

Public ReadOnly Property Name() As String
Get
Return _name
End Get
End Property
Public ReadOnly Property Num() As Integer
Get
Return _num
End Get
End Property

Private Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

'********************************************
Public Overrides Function ToString() As String
Return Me.Name
End Function

'*********************************************

End Class

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM ||
']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM ||
']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)
'Dim reader As FbDataReader
Try
conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read
Me.Add(New nvp(reader.GetInt32(0),
reader.GetString(1)))
End While
reader.Close()
End Using

Finally
conn.Close()
End Try

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:6f******************************@comcast.com. ..
>Override the ToString method in your LookupNVP class.

By the way, when you post your code, if you paste it into Notepad, then
copy and paste it into your posting, it will retain its spacing, and be
easier to read. The easier it is to read, the more likely someone will
help you.

Robin S.


Apr 2 '07 #4
Thanks Robin,

Still no joy. All the items appear in the combobox, they just don't lookup
when the data changes.

Can you think of something else?

Public Class nvp
Private _name As String
Private _num As Integer

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Num() As Integer
Get
Return _num
End Get
Set(ByVal value As Integer)
_num = value
End Set
End Property

Public Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

Public Overrides Function ToString() As String
Return _name
End Function

End Class

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM ||
']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM ||
']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
Me.Add(New nvp(CInt(reader(0).ToString),
reader(1).ToString))
End While
reader.Close()
End Using

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Oe******************************@comcast.com. ..
Move your nvp class out of your lookupNvp class.

Public Class LookupNVP
Inherits BindingList(of nvp)
...
End Class

Public Class NVP
...
(ToString goes here)
End Class

Put the reading of the database in LookupNVP, and add each NVP object to
your list.

Robin S.

Apr 2 '07 #5
I'm not completely understanding. You're binding the data for the combobox
to the list(of nvp), right? So those items are showing just fine?

So what do you mean by "they don't lookup when data changes" ? Do you need
the combobx to be double-bound so in addition to showing a list of
possibilities, it displays the actual one selected?

To do this, set the SelectedValue property to the field in the other list
or whatever it is you are binding the rest of your controls to.

Does that help?

Robin S.
--------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Thanks Robin,

Still no joy. All the items appear in the combobox, they just don't
lookup when the data changes.

Can you think of something else?

Public Class nvp
Private _name As String
Private _num As Integer

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Num() As Integer
Get
Return _num
End Get
Set(ByVal value As Integer)
_num = value
End Set
End Property

Public Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

Public Overrides Function ToString() As String
Return _name
End Function

End Class

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM ||
']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM ||
']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
Me.Add(New nvp(CInt(reader(0).ToString),
reader(1).ToString))
End While
reader.Close()
End Using

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Oe******************************@comcast.com. ..
>Move your nvp class out of your lookupNvp class.

Public Class LookupNVP
Inherits BindingList(of nvp)
...
End Class

Public Class NVP
...
(ToString goes here)
End Class

Put the reading of the database in LookupNVP, and add each NVP object to
your list.

Robin S.


Apr 3 '07 #6
Yes, you got it.

In this specific case I am loading all the possible terms into the cb using
their descriptions for the text in the combo box. The terms number is the
cb value member.

The selected value is the purchase order terms number.

All of the terms descriptions show in the cb after I bind DisplayMember and
ValueMember, but when I move to a purchase order the cb shows a blank
selection rather than the corresponding terms description (displaymember).

I am binding the cb like this:

cbTerms.DisplayMember = "Name"

cbTerms.ValueMember = "Num"

cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)

cbTerms.DataBindings.Clear()

cbTerms.DataBindings.Add("SelectedValue", PObind, "Termsnum")

So what I assume is happening is that a change in the purchase order
termsnum causes a lookup in the LookupNVP binding list(of NVP) and since it
does not locate the value it returns -1.

BTW when I create a datatable/tableadapter/bindingsource for the terms and
bind this to the cb, everything works as expected. I just don't need all
this extra overhead for the fixed terms choices so I wanted to cut it to the
minimum with a fixed list bound to the cb.

Thanks for your persistance.

Rick

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:9r******************************@comcast.com. ..
I'm not completely understanding. You're binding the data for the combobox
to the list(of nvp), right? So those items are showing just fine?

So what do you mean by "they don't lookup when data changes" ? Do you need
the combobx to be double-bound so in addition to showing a list of
possibilities, it displays the actual one selected?

To do this, set the SelectedValue property to the field in the other list
or whatever it is you are binding the rest of your controls to.

Does that help?

Robin S.
--------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Thanks Robin,

Still no joy. All the items appear in the combobox, they just don't
lookup when the data changes.

Can you think of something else?

Public Class nvp
Private _name As String
Private _num As Integer

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Num() As Integer
Get
Return _num
End Get
Set(ByVal value As Integer)
_num = value
End Set
End Property

Public Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

Public Overrides Function ToString() As String
Return _name
End Function

End Class

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM ||
']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM ||
']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnection )
While reader.Read()
Me.Add(New nvp(CInt(reader(0).ToString),
reader(1).ToString))
End While
reader.Close()
End Using

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Oe******************************@comcast.com ...
>>Move your nvp class out of your lookupNvp class.

Public Class LookupNVP
Inherits BindingList(of nvp)
...
End Class

Public Class NVP
...
(ToString goes here)
End Class

Put the reading of the database in LookupNVP, and add each NVP object to
your list.

Robin S.



Apr 3 '07 #7

Why are you doing this? You're clearing the data binding on your combobox
after you've set it.
cbTerms.DataBindings.Clear()
Try this:

cbTerms.DataBindings.Add(New Binding("SelectedValue", PObind, "Termsnum",
True))
cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)
cbTerms.DisplayMember = "Name"
cbTerms.ValueMember = "Num"
Robin S.
-------------------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Yes, you got it.

In this specific case I am loading all the possible terms into the cb
using their descriptions for the text in the combo box. The terms number
is the cb value member.

The selected value is the purchase order terms number.

All of the terms descriptions show in the cb after I bind DisplayMember
and ValueMember, but when I move to a purchase order the cb shows a blank
selection rather than the corresponding terms description
(displaymember).

I am binding the cb like this:

cbTerms.DisplayMember = "Name"

cbTerms.ValueMember = "Num"

cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)

cbTerms.DataBindings.Clear()

cbTerms.DataBindings.Add("SelectedValue", PObind, "Termsnum")

So what I assume is happening is that a change in the purchase order
termsnum causes a lookup in the LookupNVP binding list(of NVP) and since
it does not locate the value it returns -1.

BTW when I create a datatable/tableadapter/bindingsource for the terms
and bind this to the cb, everything works as expected. I just don't need
all this extra overhead for the fixed terms choices so I wanted to cut it
to the minimum with a fixed list bound to the cb.

Thanks for your persistance.

Rick

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:9r******************************@comcast.com. ..
>I'm not completely understanding. You're binding the data for the
combobox to the list(of nvp), right? So those items are showing just
fine?

So what do you mean by "they don't lookup when data changes" ? Do you
need the combobx to be double-bound so in addition to showing a list of
possibilities, it displays the actual one selected?

To do this, set the SelectedValue property to the field in the other
list or whatever it is you are binding the rest of your controls to.

Does that help?

Robin S.
--------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Thanks Robin,

Still no joy. All the items appear in the combobox, they just don't
lookup when the data changes.

Can you think of something else?

Public Class nvp
Private _name As String
Private _num As Integer

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Num() As Integer
Get
Return _num
End Get
Set(ByVal value As Integer)
_num = value
End Set
End Property

Public Sub New()
End Sub

Public Sub New(ByVal newValue As Integer, ByVal newName As String)
_name = newName
_num = newValue
End Sub

Public Overrides Function ToString() As String
Return _name
End Function

End Class

Public Class LookupNVP
Inherits BindingList(Of nvp)

Public Enum listType
Terms
Shipvia
End Enum

Public Sub New(ByVal list As listType, ByVal conn As FbConnection)
MyBase.New()
Dim sql As String
Select Case list
Case listType.Shipvia
sql = "Select SHIPVIANUM, METHOD || ' [' || SHIPVIANUM
|| ']' " _
& "from SHIPVIA order by METHOD"
Case listType.Terms
sql = "Select TERMSNUM, DESCRIPTION || ' [' || TERMSNUM
|| ']' " _
& "from TERMS order by DESCRIPTION"
End Select

If sql Is Nothing Then Return

Dim cmd As FbCommand = New FbCommand(sql, conn)

conn.Open()
Using reader As FbDataReader =
cmd.ExecuteReader(CommandBehavior.CloseConnectio n)
While reader.Read()
Me.Add(New nvp(CInt(reader(0).ToString),
reader(1).ToString))
End While
reader.Close()
End Using

End Sub

End Class

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Oe******************************@comcast.co m...
Move your nvp class out of your lookupNvp class.

Public Class LookupNVP
Inherits BindingList(of nvp)
...
End Class

Public Class NVP
...
(ToString goes here)
End Class

Put the reading of the database in LookupNVP, and add each NVP object
to your list.

Robin S.




Apr 4 '07 #8
I was doing the cbTerms.DataBindings.Clear() because the databindings were
already set in the designer for the datatable connection that I am using in
the meantime.

No, that doesn't work either. The "lookup" does not happen so when I change
rows in the PurchaseOrder table, the terms combo box has an index of -1.

Do you by chance have any example code for a class anything like this that
does work as a source for a lookup combo box? That might be easier for me
to adapt.

Thanks,

Rick
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:TI******************************@comcast.com. ..
>
Why are you doing this? You're clearing the data binding on your combobox
after you've set it.
>cbTerms.DataBindings.Clear()

Try this:

cbTerms.DataBindings.Add(New Binding("SelectedValue", PObind, "Termsnum",
True))
cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)
cbTerms.DisplayMember = "Name"
cbTerms.ValueMember = "Num"
Robin S.

Apr 4 '07 #9
Yes, I do, but I don't have time to post it tonight, and I'm going to be in
an all-day design meeting tomorrow. :-( I'll try to get to it on Friday,
unless I do it tomorrow night (50/50 chance).

Robin S.
----------------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I was doing the cbTerms.DataBindings.Clear() because the databindings were
already set in the designer for the datatable connection that I am using
in the meantime.

No, that doesn't work either. The "lookup" does not happen so when I
change rows in the PurchaseOrder table, the terms combo box has an index
of -1.

Do you by chance have any example code for a class anything like this
that does work as a source for a lookup combo box? That might be easier
for me to adapt.

Thanks,

Rick
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:TI******************************@comcast.com. ..
>>
Why are you doing this? You're clearing the data binding on your
combobox after you've set it.
>>cbTerms.DataBindings.Clear()

Try this:

cbTerms.DataBindings.Add(New Binding("SelectedValue", PObind,
"Termsnum", True))
cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms, fMain.conn)
cbTerms.DisplayMember = "Name"
cbTerms.ValueMember = "Num"
Robin S.


Apr 5 '07 #10
Rick,
I'm e-mailing you a small project. Too much to post here.
Robin S.
-------------------------------
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Wu******************************@comcast.com. ..
Yes, I do, but I don't have time to post it tonight, and I'm going to be
in an all-day design meeting tomorrow. :-( I'll try to get to it on
Friday, unless I do it tomorrow night (50/50 chance).

Robin S.
----------------------------------
"Rick" <Ri**@LakeValleySeed.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I was doing the cbTerms.DataBindings.Clear() because the databindings
were already set in the designer for the datatable connection that I am
using in the meantime.

No, that doesn't work either. The "lookup" does not happen so when I
change rows in the PurchaseOrder table, the terms combo box has an index
of -1.

Do you by chance have any example code for a class anything like this
that does work as a source for a lookup combo box? That might be easier
for me to adapt.

Thanks,

Rick
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:TI******************************@comcast.com ...
>>>
Why are you doing this? You're clearing the data binding on your
combobox after you've set it.

cbTerms.DataBindings.Clear()

Try this:

cbTerms.DataBindings.Add(New Binding("SelectedValue", PObind,
"Termsnum", True))
cbTerms.DataSource = New LookupNVP(LookupNVP.listType.Terms,
fMain.conn)
cbTerms.DisplayMember = "Name"
cbTerms.ValueMember = "Num"
Robin S.



Apr 9 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: hazz | last post by:
The data access layer below returns, well, a mess as you can see on the last line of this posting. What is the best way to return customer objects via a datareader from the data layer into my view...
1
by: Dave Booker | last post by:
Is there a reason why the BindingList constructor doesn't create a new BindingList? Create a form with four ListBoxes and the following will result in them all containing the exact same thing. ...
1
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the...
3
by: Bryan | last post by:
I am calling BindingList.EndEdit during a 'TextChanged' sub for a texbox. In theory, the key should be pressed changing the value in the text box, the EndEdit call should append the changes to the...
5
by: Mike Surcouf | last post by:
Hi All I have a stored procedure wrapper that returns Collection<T>. The wrapper is generated by codesmith so I don't really want to start altering it. I need to use this collection in a...
1
by: Pieter | last post by:
Hi, I use a customized Generic List (VB.NET 2.0) inherited from BindingList(Of T). I made some methods in this BindingList, to allow me to do some standard functions on the BindingList-Items....
6
by: jwilson128 | last post by:
I am trying to decide whether to use a system.ComponentModel.BindingList(of T) or a Sytem.Collections.Generic.List(of T) for a custom collection. In testing a simple, read-only data binding to a...
1
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a ComboBox named comboBoxSelChannel. I declared a structure named MySturct. public struct MyStruct { public int Index; public string Name;
3
by: jehugaleahsa | last post by:
Hello: I am binding a DataGridView with a BindingList<T>, where T is a custom business object that implements INotifyPropertyChanged. When you bind a DataGridView to a DataTable, it has this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.