I have created a form which sets up a dataview. The form views one
record at a time using a currencymanager. This works fine. All my
text boxes bind.
However I have a combo box which gets its lookup values from another
(Advertising) table (AdvertisingID, Advertising). This works
.. However, where it doesn't work as well is when the form
loads, the combo boxes should bind to the AdvertisingID field and
display the respective data.
When the form loads the combo box only displays a blank. If I
select the combo box all the values from the lookup table are there.
But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and
just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:-
Richard 10 1882
Hi,
Please post some code.
Ken
--------------
"Richard" <xx******************@yahoo.co.uk> wrote in message
news:4c********************************@4ax.com...
I have created a form which sets up a dataview. The form views one
record at a time using a currencymanager. This works fine. All my
text boxes bind.
However I have a combo box which gets its lookup values from another
(Advertising) table (AdvertisingID, Advertising). This works
.. However, where it doesn't work as well is when the form
loads, the combo boxes should bind to the AdvertisingID field and
display the respective data.
When the form loads the combo box only displays a blank. If I
select the combo box all the values from the lookup table are there.
But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and
just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:-
Richard
objDataSet = New DataSet
objDataAdapter.Fill(objDataSet, "Sellers")
objDataView = New DataView(objDataSet.Tables("Sellers"))
objCurrencyManager = CType(Me.BindingContext(objDataView),
CurrencyManager)
Creating the bindings. This gets called on loading the form. I've
stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _
"FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection)
cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo)
Dim arrAdvertising As New ArrayList
Try
cnnOTwo.Open()
drSQL =
cmdAdvertising.ExecuteReader(CommandBehavior.Close Connection)
While drSQL.Read
arrAdvertising.Add(New Category(drSQL.GetByte(0),
drSQL.GetString(1)))
End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException
MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text)
End Try
With cboAdvertising
.DataSource = arrAdvertising
.ValueMember = "ID"
.DisplayMember = "Name"
.Add("SelectedValue", objDataView, "AdvertisingMedium")
End With
It all works fine. The only bit I'm trying to understand is why the
combo box does not display the value of the underlying field that it
is (or should be) bound to.
On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com.. . I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Hi,
Are Name and ID properties in the Category class?
Ken
-------------------
"Richard" <xx******************@yahoo.co.uk> wrote in message
news:d1********************************@4ax.com...
objDataSet = New DataSet
objDataAdapter.Fill(objDataSet, "Sellers")
objDataView = New DataView(objDataSet.Tables("Sellers"))
objCurrencyManager = CType(Me.BindingContext(objDataView),
CurrencyManager)
Creating the bindings. This gets called on loading the form. I've
stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _
"FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection)
cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo)
Dim arrAdvertising As New ArrayList
Try
cnnOTwo.Open()
drSQL =
cmdAdvertising.ExecuteReader(CommandBehavior.Close Connection)
While drSQL.Read
arrAdvertising.Add(New Category(drSQL.GetByte(0),
drSQL.GetString(1)))
End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException
MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text)
End Try
With cboAdvertising
.DataSource = arrAdvertising
.ValueMember = "ID"
.DisplayMember = "Name"
.Add("SelectedValue", objDataView, "AdvertisingMedium")
End With
It all works fine. The only bit I'm trying to understand is why the
combo box does not display the value of the underlying field that it
is (or should be) bound to.
On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com.. . I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.com.. . objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.Clos eConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com. .. I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005
there is no add method for the combobox. Where did that line come from?
Ken
------------------
"Richard" <xx******************@yahoo.co.uk> wrote in message
news:o5********************************@4ax.com...
Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.com.. . objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.Clos eConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com. .. I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Thank you for your help Ken. I see what you mean. I've just changed
this line to
With cboAdvertising
.DataSource = arrAdvertising
.ValueMember = "ID"
.DisplayMember = "Name"
.DataBindings.Add("SelectedValue", objDataView,
"AdvertisingMedium")
End With
But the only difference I can make is if I try to bind the combobox
before adding the Datasource, Valuemember and Displaymember
propertties, there is a blank in the combobox, and if I bind the the
combobox to the field afterwards (as shown) the form loads with the
first value in the combobox selected.
Still cannot get it to display the actual data in the field when the
form loads though!
Richard
On Fri, 15 Jul 2005 06:08:45 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005 there is no add method for the combobox. Where did that line come from?
Ken ------------------ "Richard" <xx******************@yahoo.co.uk> wrote in message news:o5********************************@4ax.com.. . Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.com. .. objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.Clo seConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com ... I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Hi,
You are setting the datasource, displaymember, and valuemember.
You do not need the databindings.add line.
Ken
-------------
"Richard" <xx******************@yahoo.co.uk> wrote in message
news:tu********************************@4ax.com...
Thank you for your help Ken. I see what you mean. I've just changed
this line to
With cboAdvertising
.DataSource = arrAdvertising
.ValueMember = "ID"
.DisplayMember = "Name"
.DataBindings.Add("SelectedValue", objDataView,
"AdvertisingMedium")
End With
But the only difference I can make is if I try to bind the combobox
before adding the Datasource, Valuemember and Displaymember
propertties, there is a blank in the combobox, and if I bind the the
combobox to the field afterwards (as shown) the form loads with the
first value in the combobox selected.
Still cannot get it to display the actual data in the field when the
form loads though!
Richard
On Fri, 15 Jul 2005 06:08:45 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005 there is no add method for the combobox. Where did that line come from?
Ken ------------------ "Richard" <xx******************@yahoo.co.uk> wrote in message news:o5********************************@4ax.com.. . Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.com. .. objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.Clo seConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.com ... I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Hi Ken,
Sorry if I've confused things.
The datasource of the combobox is merely the lookup table that
provides the primary key and description values for the arraylist
which then populates the displaymember and valuemember properties
combobox.
Without the databindings.add line, there is nothing to bind the
combobox to the foreign key of the form's datasource.
Richard
On Fri, 15 Jul 2005 17:31:53 -0400, "Ken Tucker [MVP]"
<vb***@bellsouth.net> wrote: Hi,
You are setting the datasource, displaymember, and valuemember. You do not need the databindings.add line.
Ken ------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:tu********************************@4ax.com.. . Thank you for your help Ken. I see what you mean. I've just changed this line to
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .DataBindings.Add("SelectedValue", objDataView, "AdvertisingMedium") End With
But the only difference I can make is if I try to bind the combobox before adding the Datasource, Valuemember and Displaymember propertties, there is a blank in the combobox, and if I bind the the combobox to the field afterwards (as shown) the form loads with the first value in the combobox selected.
Still cannot get it to display the actual data in the field when the form loads though!
Richard
On Fri, 15 Jul 2005 06:08:45 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005 there is no add method for the combobox. Where did that line come from?
Ken ------------------ "Richard" <xx******************@yahoo.co.uk> wrote in message news:o5********************************@4ax.com. .. Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.com ... objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.Cl oseConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Please post some code.
Ken -------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:4c********************************@4ax.co m... I have created a form which sets up a dataview. The form views one record at a time using a currencymanager. This works fine. All my text boxes bind.
However I have a combo box which gets its lookup values from another (Advertising) table (AdvertisingID, Advertising). This works . However, where it doesn't work as well is when the form loads, the combo boxes should bind to the AdvertisingID field and display the respective data.
When the form loads the combo box only displays a blank. If I select the combo box all the values from the lookup table are there. But why doesn't it display the value when the form loads.
Please help. This has been driving me nuts for three days already and just cannot figure out what the problem is.
I'll post my code:-
Creating the dataview and currency manager:- Richard
Sorry Ken,
My I am just trying to load the value that is already in the form's
dataset to display in the combo box when the form loads. I've taken
that line out but it does nothing.
Richard
On Fri, 15 Jul 2005 23:24:14 +0100, Richard
<xx******************@yahoo.co.uk> wrote: Hi Ken,
Sorry if I've confused things.
The datasource of the combobox is merely the lookup table that provides the primary key and description values for the arraylist which then populates the displaymember and valuemember properties combobox.
Without the databindings.add line, there is nothing to bind the combobox to the foreign key of the form's datasource.
Richard
On Fri, 15 Jul 2005 17:31:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
You are setting the datasource, displaymember, and valuemember. You do not need the databindings.add line.
Ken ------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:tu********************************@4ax.com. .. Thank you for your help Ken. I see what you mean. I've just changed this line to
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .DataBindings.Add("SelectedValue", objDataView, "AdvertisingMedium") End With
But the only difference I can make is if I try to bind the combobox before adding the Datasource, Valuemember and Displaymember propertties, there is a blank in the combobox, and if I bind the the combobox to the field afterwards (as shown) the form loads with the first value in the combobox selected.
Still cannot get it to display the actual data in the field when the form loads though!
Richard
On Fri, 15 Jul 2005 06:08:45 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005 there is no add method for the combobox. Where did that line come from?
Ken ------------------ "Richard" <xx******************@yahoo.co.uk> wrote in message news:o5********************************@4ax.com ... Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
Are Name and ID properties in the Category class?
Ken ------------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:d1********************************@4ax.co m... objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "Sellers") objDataView = New DataView(objDataSet.Tables("Sellers")) objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)
Creating the bindings. This gets called on loading the form. I've stripped the bindings of text boxes etc.
Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ "FROM AdvertisingMedium"
cboAdvertising.DataBindings.Clear()
cnnOTwo = New SqlConnection(strConnection) cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) Dim arrAdvertising As New ArrayList
Try cnnOTwo.Open() drSQL = cmdAdvertising.ExecuteReader(CommandBehavior.C loseConnection)
While drSQL.Read arrAdvertising.Add(New Category(drSQL.GetByte(0), drSQL.GetString(1))) End While
drSQL.Close()
cnnOTwo.Close()
Catch exsql As SqlException MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) End Try
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .Add("SelectedValue", objDataView, "AdvertisingMedium") End With
It all works fine. The only bit I'm trying to understand is why the combo box does not display the value of the underlying field that it is (or should be) bound to. On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
>Hi, > > Please post some code. > >Ken >-------------- >"Richard" <xx******************@yahoo.co.uk> wrote in message >news:4c********************************@4ax.c om... >I have created a form which sets up a dataview. The form views one >record at a time using a currencymanager. This works fine. All my >text boxes bind. > >However I have a combo box which gets its lookup values from another >(Advertising) table (AdvertisingID, Advertising). This works >. However, where it doesn't work as well is when the form >loads, the combo boxes should bind to the AdvertisingID field and >display the respective data. > >When the form loads the combo box only displays a blank. If I >select the combo box all the values from the lookup table are there. >But why doesn't it display the value when the form loads. > >Please help. This has been driving me nuts for three days already and >just cannot figure out what the problem is. > >I'll post my code:- > >Creating the dataview and currency manager:- > > > > > > >Richard >
I've sorted this problem out now. I've got rid of the class I was
using and used a dataset/dataadapter method.
Much simpler.
Richard
On Sun, 17 Jul 2005 14:08:23 +0100, Richard
<xx******************@yahoo.co.uk> wrote: Sorry Ken,
My I am just trying to load the value that is already in the form's dataset to display in the combo box when the form loads. I've taken that line out but it does nothing.
Richard On Fri, 15 Jul 2005 23:24:14 +0100, Richard <xx******************@yahoo.co.uk> wrote:
Hi Ken,
Sorry if I've confused things.
The datasource of the combobox is merely the lookup table that provides the primary key and description values for the arraylist which then populates the displaymember and valuemember properties combobox.
Without the databindings.add line, there is nothing to bind the combobox to the foreign key of the form's datasource.
Richard
On Fri, 15 Jul 2005 17:31:53 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
You are setting the datasource, displaymember, and valuemember. You do not need the databindings.add line.
Ken ------------- "Richard" <xx******************@yahoo.co.uk> wrote in message news:tu********************************@4ax.com ... Thank you for your help Ken. I see what you mean. I've just changed this line to
With cboAdvertising .DataSource = arrAdvertising .ValueMember = "ID" .DisplayMember = "Name" .DataBindings.Add("SelectedValue", objDataView, "AdvertisingMedium") End With
But the only difference I can make is if I try to bind the combobox before adding the Datasource, Valuemember and Displaymember propertties, there is a blank in the combobox, and if I bind the the combobox to the field afterwards (as shown) the form loads with the first value in the combobox selected.
Still cannot get it to display the actual data in the field when the form loads though!
Richard
On Fri, 15 Jul 2005 06:08:45 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
Hi,
I looked at you code again. In vs.net 2002, 2003, and 2005 there is no add method for the combobox. Where did that line come from?
Ken ------------------ "Richard" <xx******************@yahoo.co.uk> wrote in message news:o5********************************@4ax.co m... Yes that's right!
Richard
On Thu, 14 Jul 2005 20:50:55 -0400, "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote:
>Hi, > > Are Name and ID properties in the Category class? > >Ken >------------------- >"Richard" <xx******************@yahoo.co.uk> wrote in message >news:d1********************************@4ax.c om... >objDataSet = New DataSet >objDataAdapter.Fill(objDataSet, "Sellers") >objDataView = New DataView(objDataSet.Tables("Sellers")) >objCurrencyManager = CType(Me.BindingContext(objDataView), >CurrencyManager) > > >Creating the bindings. This gets called on loading the form. I've >stripped the bindings of text boxes etc. > >Dim strAdvertising As String = "SELECT AdvertID, Advertising " & _ >"FROM AdvertisingMedium" > >cboAdvertising.DataBindings.Clear() > >cnnOTwo = New SqlConnection(strConnection) >cmdAdvertising = New SqlCommand(strAdvertising, cnnOTwo) >Dim arrAdvertising As New ArrayList > >Try > cnnOTwo.Open() > drSQL = >cmdAdvertising.ExecuteReader(CommandBehavior. CloseConnection) > > While drSQL.Read > arrAdvertising.Add(New Category(drSQL.GetByte(0), >drSQL.GetString(1))) > End While > > drSQL.Close() > > cnnOTwo.Close() > > Catch exsql As SqlException > MsgBox(exsql.ToString, MsgBoxStyle.Critical, Me.Text) >End Try > >With cboAdvertising > .DataSource = arrAdvertising > .ValueMember = "ID" > .DisplayMember = "Name" > .Add("SelectedValue", objDataView, "AdvertisingMedium") >End With > > >It all works fine. The only bit I'm trying to understand is why the >combo box does not display the value of the underlying field that it >is (or should be) bound to. > > > >On Thu, 14 Jul 2005 18:12:53 -0400, "Ken Tucker [MVP]" ><vb***@bellsouth.net> wrote: > >>Hi, >> >> Please post some code. >> >>Ken >>-------------- >>"Richard" <xx******************@yahoo.co.uk> wrote in message >>news:4c********************************@4ax. com... >>I have created a form which sets up a dataview. The form views one >>record at a time using a currencymanager. This works fine. All my >>text boxes bind. >> >>However I have a combo box which gets its lookup values from another >>(Advertising) table (AdvertisingID, Advertising). This works >>. However, where it doesn't work as well is when the form >>loads, the combo boxes should bind to the AdvertisingID field and >>display the respective data. >> >>When the form loads the combo box only displays a blank. If I >>select the combo box all the values from the lookup table are there. >>But why doesn't it display the value when the form loads. >> >>Please help. This has been driving me nuts for three days already and >>just cannot figure out what the problem is. >> >>I'll post my code:- >> >>Creating the dataview and currency manager:- >> >> >> >> >> >> >>Richard >> >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CGuy |
last post by:
URGENT HELP REQUIRED FROM GURUS
Hi,
I have a custom object that implements ICollection and IListSource. This
object has also an enumerator defined for it which implements IEnumerator
and...
|
by: kk |
last post by:
Have 2 problems, any help is appreciated.
Tab with Grids
--------------
BL - fetching data from DB ( 5 secs - 10 rows)
Grid Laod - 20 secs
Grid Paint on tab change - 20 secs
Problem: The...
|
by: kk |
last post by:
I have 2 issues, please help !
1st issue :
--------------------------------------------------------
Loading Grid
------------
1) creating new rows in a datatable and adding data a
array...
|
by: Nathan Carroll |
last post by:
Problems with Combobox. When I bind like below. I am unable to use bm. But
as soon as I take the binding of the Combobox out bm works as it should.
bm =...
|
by: SoftWhiteDelgiht |
last post by:
Help me. I am obviously stupid! :-)
I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend.
I have created a combo box which is to populate with...
|
by: Jim Shaffer |
last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003)....
I've loaded a two-dimensional array (168 by 28) into memory as AcctArray.
{Dim AcctArray (500,28) as string...}
The...
|
by: Steve |
last post by:
C#
I have some combo boxes, full of lookup descriptions. When I retrieve a
dataset for my record, the values that need binding to the combos are the
actual record IDs that relate to these...
|
by: Bill |
last post by:
I have what I think should be a simple question regarding a bound combo box.
My first table is Dealers:
DealerID - primary key
DealerName
BillToLocation
My second table is Locations:...
|
by: Monty M. |
last post by:
Does anyone know how to perform two way data binding between a combo
box and a listview.
The listview is bound to a dataset table in code:
Binding Bind = new Binding();
DataTable dt;...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |