473,407 Members | 2,326 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,407 software developers and data experts.

Combo Box Is showing default value!!!

77
Hi All,

I have problem with combo box. It is funny but I don't know what to do. When I load my form I load my combos with this Sub:
Expand|Select|Wrap|Line Numbers
  1.     Private Sub CityLoad()
  2.         Dim sql As String
  3.  
  4.         Dim ds1 As New DataSet
  5.         Dim ds2 As New DataSet
  6.         Dim con As SqlConnection
  7.         Dim da As SqlDataAdapter
  8.         sql = "SELECT *  FROM tbl_city"
  9.         con = New SqlConnection(StrCon)
  10.         con.Open()
  11.         da = New SqlDataAdapter(sql, con)
  12.         '***CityIni
  13.         da.Fill(ds1)
  14.         cboCityIni.DataSource = ds1.Tables(0)
  15.         cboCityIni.ValueMember = ds1.Tables(0).Columns  (0).ColumnName.ToString
  16.         cboCityIni.DisplayMember = ds1.Tables(0).Columns(1).ColumnName.ToString
  17.         cboCityIni.Text = ""
  18.         ds1 = Nothing
  19.         '***CitySec
  20.         da.Fill(ds2)
  21.         cboCitySec.DataSource = ds2.Tables(0)
  22.         cboCitySec.ValueMember = ds2.Tables(0).Columns(0).ColumnName.ToString
  23.         cboCitySec.DisplayMember = ds2.Tables(0).Columns(1).ColumnName.ToString
  24.         cboCitySec.Text = ""
  25.  
  26.     End Sub
  27.  
Both of these combos are loaded with City but the problem is when I run the application I need to see empty combo(I mean it should not show any value till the user click on them.)
Surprizingly second combo is showing the first item in the combo when form is loaded.

What should I do?
Aug 6 '08 #1
4 1400
Plater
7,872 Expert 4TB
Add a blank row to the begining of your datatable? Really I am surprised that they both did not autoselect the first value
Aug 6 '08 #2
Sep410
77
Thanks .
Can you tell me how to do that?
Aug 6 '08 #3
Sep410
77
I found a easy way

Combo.SelectedValue = 0
Aug 7 '08 #4
Plater
7,872 Expert 4TB
Ahh ses I assumed you already had that. you DO have a blank link at the begining, good.
Not sure why it didn't default to that position. Glad you found a fix.
Aug 7 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
3
by: ken | last post by:
Hi, I want to reset the default value of a combo box everytime someone selects something from its list. I have in the after update event combo.defaultvalue = combo.value. Anyhow this works, as...
6
by: carmela_wong | last post by:
Hello all, I am trying to set the default value of a combo box to "USA" which does not work although I have entered this in the Default Value property of the control. The combo box shows the...
4
by: Torilyn73 | last post by:
I have a combo box set up off a query. I want the default value to be the column heading so I don't have to put a label over it. So far I haven't been able to figure this out. Can anyone tell me if...
2
by: Brad Pears | last post by:
In my vb.net 2005 project I have a few combo boxes where I want to set a default value. I am not binding these combo boxes - I am loading the values directly in code from a dataset. Obviously...
10
by: Declining | last post by:
Hello All, I’d like to make an enquiry as to how to set the default value in a combo box to the previously select value in MS access 2003. I have 50 or so possible items that can be selected...
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
4
by: sierra7 | last post by:
Hi all I have a situation where I have an existing form that has funcioned well for years but is giving a problem running in Access 2010. There are two combo boxes in the header of a form, which set...
3
by: Adam Tippelt | last post by:
I've got a combo box that runs a query and returns a list of items, based on a value in a different combo box. The query runs perfectly and the combo box list is filled with the correct selection...
0
BarryA
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...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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 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.