473,507 Members | 5,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to return value in Combobox

Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #1
6 3484
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #2
Hi trevish,

Thanks for your answer,
My realy question also = how to bind directly to database, now i have a
textbox bound
Me.txtAdresType.DataBindings.Add("text", bsAdressen, "AdresType")

If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return to
the previous old value.
How to fix?
Or how to databind the combobox "cboTypeAdres" direcly
best regards,
Marc.


"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
>Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc

Sep 13 '06 #3
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return to
the previous old value.
>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #4
both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
>If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return
to
the previous old value.
>>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegr oups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc

Sep 13 '06 #5
what about txtTypeAdress.focus() before you save?
Scotty wrote:
both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googlegr oups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.
If I select my combo, the update in the textbox is working fine but if i
will save the data and the textbox hans't been selected the value return
to
the previous old value.
>

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is the
bounded
text ?

Many thanks in advance

Marc
Sep 13 '06 #6

Hi, Ive found it, see code below
Many thx for your idea's
By adding the refrech to txtAdresType
Private Sub cboTypeAdres_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboTypeAdres.SelectedIndexChanged

Me.txtAdresType.Text = CStr(Me.cboTypeAdres.SelectedIndex)

Me.txtAdresType.Focus()

Me.txtAdresType.Refresh()

End Sub
Marc.


"trevisc" <tr*****@gmail.comschreef in bericht
news:11********************@e3g2000cwe.googlegroup s.com...
what about txtTypeAdress.focus() before you save?
Scotty wrote:
>both does not work
On cboTypeAdres_SelectedIndexChanged the index value goes into
txtTypeAdress

Only after i select manualy txtTypeAdress the update function will
succeed

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@m73g2000cwd.googleg roups.com...
hmm..can you just put

cboTypeAdres.Focus() in the click event of the Save button?

still not sure if i'm understanding the problem but if by clicking in a
box it somehow refreshes your combo box then either do
cboTypeAdres.refresh or just set focus to the combobox before you run
the save routine.

If I select my combo, the update in the textbox is working fine but if
i
will save the data and the textbox hans't been selected the value
return
to
the previous old value.

"trevisc" <tr*****@gmail.comschreef in bericht
news:11**********************@i3g2000cwc.googlegr oups.com...
If you don't have the ability to add the name to your Database table
then the best way to do it is set a variable equal to the combobox
SelectedIndex and send that.

Put something like this code in the click event of a btnSave:

Dim iAdresType as Integer

iAdresType = cboTypeAdres.SelectedIndex

SelectedIndex is zero based so you can put the combobox items in
order
that they are on the database.

You could also use a Select Case statement that looks at the
cboTypeAdres.Text and sends the appropriate SelectedIndex.

Hope that helps!

trevisc

Scotty wrote:
Hi, I need some info

How to return the value from the database
My combobox
Me.cboTypeAdres.Items.Add("Type Adres")
Me.cboTypeAdres.Items.Add("Leverancier")
Me.cboTypeAdres.Items.Add("Klant")

the value in the database = 0 ; 1 or 2

How to return the text using the value index so that the view is
the
bounded
text ?

Many thanks in advance

Marc


Sep 14 '06 #7

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

Similar topics

5
2280
by: keith | last post by:
This may seem simple, but I'm having a bit of trouble figuring out exactly how to do it. I'm accessing a database through an ODBC link, and I have a query that returns only jobs completed that day...
8
12066
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
14793
by: PC Datasheet | last post by:
In a form/subform I have an unbound combobox in the form header that sets the value of a field in the subform so that it does not have to be entered for each record. In the BeforeUpdate event of...
3
1338
by: Mike Hoff | last post by:
Hello, I am trying to write a function that will return the value to be stored from any control based on the control's type. So for text boxes and labels it would return the text value, for...
6
4883
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
10
2068
by: news.microsoft.com | last post by:
I am new to this so bear with me. I have a set of combo boxes. Lets call them ComboBox1 and ComboBox2. ComboBox1 items are pulled from a table. When a user selects a certain item I want to...
2
8646
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
2
7114
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
1
2701
by: PIERREWHY | last post by:
I have a datagridview containing a datagridviewcombobox. The combobox has a dataset containing city_name and city_id. When I select a new city_name in the combobox I would like to return the...
0
7110
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...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
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...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
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...
0
4702
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...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.