473,379 Members | 1,330 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,379 software developers and data experts.

Combo Box

manster
I have a combo box that I want to refresh the data of after the save button is clicked. I know that in web developer you can just say datasource.databind but I do not see that in vb.net. Please can someone help me out.
Apr 16 '10 #1
12 2110
tlhintoq
3,525 Expert 2GB
I'm pretty sure a combobox has a datasource property.

http://msdn.microsoft.com/en-us/library/x8160f6f.aspx
Apr 17 '10 #2
Yes, a combo box has a datasource but my question is to refresh that datasource after I saved something to the database. I saw that when I do: mycombobox.refresh() that it repeats the data in the combobox.
Apr 17 '10 #3
tlhintoq
3,525 Expert 2GB
This is getting a little out of my area but...
What if you set the datasource to null - forcing a clear - then set the datasource back to the database - forcing it to obtain the most current values?
Apr 17 '10 #4
Yes, I'm gonna try that tommorrow. Will post here to say if it works. Thanks anyway.
Apr 18 '10 #5
to clear the combobox type this following code

"comboboxname.items.clear();"

try this following for refresing the datas in the combobox,
"databind.refresh();"
Apr 19 '10 #6
Frinavale
9,735 Expert Mod 8TB
There is no DataBind method for the combobox.
You should just be able to set the datasource to nothing and it should refresh. You may need to call the Update or the Refresh method for the combobox to force it to redraw on the page (as empty).
Apr 27 '10 #7
OK, I promised to post here when I came right and I did not exactly come right but I saw how the first combo box was done. The person read through a dataset in a loop and did: combobox1.items.add("datacolumn"). I did want to change it to a datasource but still has to learn how they work but I think to set the datasource to nothing and give it again sounds good. in vb.net's comboboxes or any databound controls you cannot use databind. I am busy doing other combo boxes with datasources and will come tell of my successes. Thanks for your posts here and I hope I will be able to help any of you soon.
Apr 29 '10 #8
Frinavale
9,735 Expert Mod 8TB
If you used the Add method to add the items to the ComboBox then you have to use the Remove method to remove them. Setting the datasource to nothing will not work in this case.
Apr 29 '10 #9
Yes, you are right and now I am investigating both options to see which will be the best. The additem or the datasource. Thanks for the interest.
Apr 29 '10 #10
Try ComboBox1.Update()
I dont know If it works.
May 8 '10 #11
@Frinavale
ya you're correct, we cant do databind.refresh().
May 13 '10 #12
mfaisalwarraich
194 100+
Hi,

if you are adding items into the combobox using the database i recommend you the following code:
Expand|Select|Wrap|Line Numbers
  1. With comboBox1
  2.   .DataSource = Me.YourDataSetName.YourTableName
  3.   .DisplayMember = Me.YourDataSetName.YourTableName.Columns(1).ColumnName
  4.   .ValueMember = Me.YourDataSetName.YourTableName.Columns(0).ColumnName
  5.  
  6.  
  7. End With
  8.  
This will add items into your combobox. After that you can set the datasource to nothing and then select datasource again. Here is the code:
Expand|Select|Wrap|Line Numbers
  1.                 comboBox1.DataSource = null
  2.                 comboBox1.Items.Clear()
  3.                 comboBox1.DataSource = Me.YourDataSetName.YourTableName
  4.  
i think this may help you.
May 14 '10 #13

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

Similar topics

3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
4
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of...
6
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a form with combo box field that allows the user to select from the combo box or type in the field value that may or maynot be in the combo box field. ...
2
by: Jeff Mason | last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with the combo's anchor property. I define a form which contains just a textbox and a combo box. The text box is...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
2
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
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: 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...

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.