I posted this in dotnet.languages.vb.controls but thought I'd post here as
well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and
"Description". Id contains a code and description contains the
description that is displayed in the combobox.
The dataview is generated from the dataset using dv =
ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv
txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description"
This works fine, I can read the current "Id" from the combobox using the
txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the
combobox, I can't seem to work out how to do it. I thought I could just set
the selectedvalue property to any of the vaules of "id" and the combobox
would then display the corresponding description. This appears not to be
the case. I don't know if it is getting confused by the fact that the "Id"
field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing?
Thanks in advance
Simon 7 4543
Combo box index are Zero based and incremental. Your ID column does not have
to correspond with this at all and can be any unique numbers. And yes,
selecting a dropdownlist item is done by setting the SelectedItemIndex to an
appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... I posted this in dotnet.languages.vb.controls but thought I'd post here as well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
The dataview is generated from the dataset using dv = ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description" This works fine, I can read the current "Id" from the combobox using the txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the combobox, I can't seem to work out how to do it. I thought I could just set the selectedvalue property to any of the vaules of "id" and the combobox would then display the corresponding description. This appears not to be the case. I don't know if it is getting confused by the fact that the "Id" field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing? Thanks in advance
Simon
But how do I know what the appropriate no is ???
If my datatable has for example:
Id Description
1 Ford
2 Vauxhall
3 Peugeot
6 Ferrari
and I want to set the combobox to "Ferrari" (ie ID=6).. How do I do this?
I'm trying to do : txtlookup.selectedvalue="6" but this isn't doing
what I expect!
I presume that the selecteditemindex property is an offset through the
datatable. Do I have to scan through the datatable counting how far through
the record I want actually is? Will it matter that I've set the combobox
to sort by Description??
Regards
Simon
"Mr Newbie" <he**@now.com> wrote in message
news:OP*************@TK2MSFTNGP11.phx.gbl... Combo box index are Zero based and incremental. Your ID column does not have to correspond with this at all and can be any unique numbers. And yes, selecting a dropdownlist item is done by setting the SelectedItemIndex to an appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl...I posted this in dotnet.languages.vb.controls but thought I'd post here as well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
The dataview is generated from the dataset using dv = ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description" This works fine, I can read the current "Id" from the combobox using the txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the combobox, I can't seem to work out how to do it. I thought I could just set the selectedvalue property to any of the vaules of "id" and the combobox would then display the corresponding description. This appears not to be the case. I don't know if it is getting confused by the fact that the "Id" field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing? Thanks in advance
Simon
Hi,
"Simon Verona" <no****@nomail.zzz> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl... But how do I know what the appropriate no is ???
If my datatable has for example:
Id Description 1 Ford 2 Vauxhall 3 Peugeot 6 Ferrari
and I want to set the combobox to "Ferrari" (ie ID=6).. How do I do this?
I'm trying to do : txtlookup.selectedvalue="6" but this isn't doing what I expect!
You need to know the datatype of the "ValueMember" column and if it is by
example an integer and not a string then you would use:
txtlookup.SelectedValue = 6 ' without quotes
HTH,
Greetings I presume that the selecteditemindex property is an offset through the datatable. Do I have to scan through the datatable counting how far through the record I want actually is? Will it matter that I've set the combobox to sort by Description??
Regards Simon "Mr Newbie" <he**@now.com> wrote in message news:OP*************@TK2MSFTNGP11.phx.gbl... Combo box index are Zero based and incremental. Your ID column does not have to correspond with this at all and can be any unique numbers. And yes, selecting a dropdownlist item is done by setting the SelectedItemIndex to an appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl...I posted this in dotnet.languages.vb.controls but thought I'd post here as well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
The dataview is generated from the dataset using dv = ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description" This works fine, I can read the current "Id" from the combobox using the txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the combobox, I can't seem to work out how to do it. I thought I could just set the selectedvalue property to any of the vaules of "id" and the combobox would then display the corresponding description. This appears not to be the case. I don't know if it is getting confused by the fact that the "Id" field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing? Thanks in advance
Simon
I must be doing something very wrong because that doesn't help!
Even though the "Id" field contains numerics, it is defined as a string
field.
Regards
Simon
"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl... Hi,
"Simon Verona" <no****@nomail.zzz> wrote in message news:uG**************@TK2MSFTNGP15.phx.gbl... But how do I know what the appropriate no is ???
If my datatable has for example:
Id Description 1 Ford 2 Vauxhall 3 Peugeot 6 Ferrari
and I want to set the combobox to "Ferrari" (ie ID=6).. How do I do this?
I'm trying to do : txtlookup.selectedvalue="6" but this isn't doing what I expect!
You need to know the datatype of the "ValueMember" column and if it is by example an integer and not a string then you would use:
txtlookup.SelectedValue = 6 ' without quotes
HTH, Greetings
I presume that the selecteditemindex property is an offset through the datatable. Do I have to scan through the datatable counting how far through the record I want actually is? Will it matter that I've set the combobox to sort by Description??
Regards Simon "Mr Newbie" <he**@now.com> wrote in message news:OP*************@TK2MSFTNGP11.phx.gbl... Combo box index are Zero based and incremental. Your ID column does not have to correspond with this at all and can be any unique numbers. And yes, selecting a dropdownlist item is done by setting the SelectedItemIndex to an appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... I posted this in dotnet.languages.vb.controls but thought I'd post here as well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
The dataview is generated from the dataset using dv = ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description" This works fine, I can read the current "Id" from the combobox using the txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the combobox, I can't seem to work out how to do it. I thought I could just set the selectedvalue property to any of the vaules of "id" and the combobox would then display the corresponding description. This appears not to be the case. I don't know if it is getting confused by the fact that the "Id" field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing? Thanks in advance
Simon
OK,
'For example, a delete operation
datasetMyVehicles.CarsTable.Rows.Find(
CarValueFromComboBoxInThisCaseItIs_6 ).Delete()
myDataAdapter.Update( datasetMyVehicles.CarsTable )
HTH
"Simon Verona" <no****@nomail.zzz> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl... I must be doing something very wrong because that doesn't help!
Even though the "Id" field contains numerics, it is defined as a string field.
Regards Simon "Bart Mermuys" <bm*************@hotmail.com> wrote in message news:eb**************@TK2MSFTNGP09.phx.gbl... Hi,
"Simon Verona" <no****@nomail.zzz> wrote in message news:uG**************@TK2MSFTNGP15.phx.gbl... But how do I know what the appropriate no is ???
If my datatable has for example:
Id Description 1 Ford 2 Vauxhall 3 Peugeot 6 Ferrari
and I want to set the combobox to "Ferrari" (ie ID=6).. How do I do this?
I'm trying to do : txtlookup.selectedvalue="6" but this isn't doing what I expect!
You need to know the datatype of the "ValueMember" column and if it is by example an integer and not a string then you would use:
txtlookup.SelectedValue = 6 ' without quotes
HTH, Greetings
I presume that the selecteditemindex property is an offset through the datatable. Do I have to scan through the datatable counting how far through the record I want actually is? Will it matter that I've set the combobox to sort by Description??
Regards Simon "Mr Newbie" <he**@now.com> wrote in message news:OP*************@TK2MSFTNGP11.phx.gbl... Combo box index are Zero based and incremental. Your ID column does not have to correspond with this at all and can be any unique numbers. And yes, selecting a dropdownlist item is done by setting the SelectedItemIndex to an appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... >I posted this in dotnet.languages.vb.controls but thought I'd post here >as well.. > > > I have a combobox that is bound to a dataview generated from a > dataset. > > The dataset has a single table (called "Data") with two columns "Id" > and "Description". Id contains a code and description contains the > description that is displayed in the combobox. > > The dataview is generated from the dataset using dv = > ds.Tables("Data").DefaultView. > > The Combobox is bound using : > > txtLookup.DataSource = dv > txtLookup.ValueMember = "Id" > > txtLookup.DisplayMember = "Description" > > > > This works fine, I can read the current "Id" from the combobox using > the txtlookup.selectedvalue property. > > However, if I want to programatically set the starting value of the > combobox, I can't seem to work out how to do it. I thought I could > just set the selectedvalue property to any of the vaules of "id" and > the combobox would then display the corresponding description. This > appears not to be the case. I don't know if it is getting confused by > the fact that the "Id" field in the datatable is numeric or if I'm > just doing it wrong! > > What should I be doing? > > > > Thanks in advance > > Simon > >
Hi,
"Simon Verona" <no****@nomail.zzz> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl... I must be doing something very wrong because that doesn't help!
Even though the "Id" field contains numerics, it is defined as a string field.
It would be strange that a numeric field would have a string datatype but it
shouldn't matter for the ComboBox, as long as you use the same type with
SelectedValue.
Check the column type (to be sure):
DataTable.Columns("id").DataType.ToString()
The ComboBox is visible and you are setting SelectedValue after the ComboBox
is bound, right ?
greetings Regards Simon "Bart Mermuys" <bm*************@hotmail.com> wrote in message news:eb**************@TK2MSFTNGP09.phx.gbl... Hi,
"Simon Verona" <no****@nomail.zzz> wrote in message news:uG**************@TK2MSFTNGP15.phx.gbl... But how do I know what the appropriate no is ???
If my datatable has for example:
Id Description 1 Ford 2 Vauxhall 3 Peugeot 6 Ferrari
and I want to set the combobox to "Ferrari" (ie ID=6).. How do I do this?
I'm trying to do : txtlookup.selectedvalue="6" but this isn't doing what I expect!
You need to know the datatype of the "ValueMember" column and if it is by example an integer and not a string then you would use:
txtlookup.SelectedValue = 6 ' without quotes
HTH, Greetings
I presume that the selecteditemindex property is an offset through the datatable. Do I have to scan through the datatable counting how far through the record I want actually is? Will it matter that I've set the combobox to sort by Description??
Regards Simon "Mr Newbie" <he**@now.com> wrote in message news:OP*************@TK2MSFTNGP11.phx.gbl... Combo box index are Zero based and incremental. Your ID column does not have to correspond with this at all and can be any unique numbers. And yes, selecting a dropdownlist item is done by setting the SelectedItemIndex to an appropriate number.
"Simon Verona" <no****@nomail.zzz> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl... >I posted this in dotnet.languages.vb.controls but thought I'd post here >as well.. > > > I have a combobox that is bound to a dataview generated from a > dataset. > > The dataset has a single table (called "Data") with two columns "Id" > and "Description". Id contains a code and description contains the > description that is displayed in the combobox. > > The dataview is generated from the dataset using dv = > ds.Tables("Data").DefaultView. > > The Combobox is bound using : > > txtLookup.DataSource = dv > txtLookup.ValueMember = "Id" > > txtLookup.DisplayMember = "Description" > > > > This works fine, I can read the current "Id" from the combobox using > the txtlookup.selectedvalue property. > > However, if I want to programatically set the starting value of the > combobox, I can't seem to work out how to do it. I thought I could > just set the selectedvalue property to any of the vaules of "id" and > the combobox would then display the corresponding description. This > appears not to be the case. I don't know if it is getting confused by > the fact that the "Id" field in the datatable is numeric or if I'm > just doing it wrong! > > What should I be doing? > > > > Thanks in advance > > Simon > >
Just to complete this thread, there was nothing actually wrong with the code
I had, the selectvalue works just fine. My problem was actually completely
unrelated to the combobox but was a corruption of the value that I was
setting the selectedvalue to!
Sometimes yuo just don't see the wood for the trees!!
Thanks
Regards
Simon
"Simon Verona" <no****@nomail.zzz> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... I posted this in dotnet.languages.vb.controls but thought I'd post here as well..
I have a combobox that is bound to a dataview generated from a dataset.
The dataset has a single table (called "Data") with two columns "Id" and "Description". Id contains a code and description contains the description that is displayed in the combobox.
The dataview is generated from the dataset using dv = ds.Tables("Data").DefaultView.
The Combobox is bound using :
txtLookup.DataSource = dv txtLookup.ValueMember = "Id"
txtLookup.DisplayMember = "Description" This works fine, I can read the current "Id" from the combobox using the txtlookup.selectedvalue property.
However, if I want to programatically set the starting value of the combobox, I can't seem to work out how to do it. I thought I could just set the selectedvalue property to any of the vaules of "id" and the combobox would then display the corresponding description. This appears not to be the case. I don't know if it is getting confused by the fact that the "Id" field in the datatable is numeric or if I'm just doing it wrong!
What should I be doing? Thanks in advance
Simon
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Smith |
last post by:
Hello all:
Another day another problem :). How do you synch a databound combobox
with the rest of the controls that are on a form. I have a combobox
that lists a bunch of names and upon...
|
by: Prem S |
last post by:
Hi All
I have a databound ComboBox control which is put into the second page
of a tab control. When the form loads up, I databind the combo control
and populate the control.
When I go to...
|
by: dbuchanan |
last post by:
VS2005
I've been reading all the help I can on the topic (MSDN, other) but I
can't make sense of this.
Desired behavior;
The user is to choose from the displayed list of the databound combobox...
|
by: Benny |
last post by:
Does anyone know how I would go about adding a blank value to the list
of items in a ComboBox that has a set datasource? Thank in advance!
|
by: greeknl via AccessMonster.com |
last post by:
Is possible to save to a variable in VBA the value a combobox had before it
was updated in order to use it because the update value can be retrieved
easily
Thank you
--
Message posted via...
|
by: daffurankan |
last post by:
Hai,
this ankan
here by this
kindly tell me that how can i save a value in combobox which is type in its text field .
on visual basic 6.0
act soon asap it is very important for me...
|
by: lttan123 |
last post by:
hi there
i am having some difficulties to bind value to combobox in windows application.
combo.Items.Add(new List("a","b"))
I have created a class.
The value is there but what is displayed...
|
by: Joel1334 |
last post by:
Hi!
How can I change forecolor of a selected value in combobox?
when I select a value in a combobox and press a button to "activate" what I've selected I want the text to be green and then...
|
by: wasim jack |
last post by:
sir,I want to change value of combobox of datagridview on the basis of previous combobox value of the same raw of same datagridview
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |