Combo Box not populating

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Combo Box not populating

 
0
  #1
Sep 20th, 2008
I have a form admission and a another form attendance.
When i click on save button of the admission form the id which is contained in that form should be added to the combo box on the attendance form.

eg. say if i am saving the details of ID 4..When i click save button on the admission form and when i open the attendance form i should c that id listed / added in the combo box of attendance form. similary the list should go on populating...as n when i add id's.....

how to do it..
my admission id text box name is txtid.text
and my combobox on attendance form name is cmbattendance.

how to do it ? plz help me out ....i am novice at vb.net so simpler the soln better..it would be.//

cya
ROHAN
AWATING A QUICK RESPONSE...

I TRIED DECLARING THE TXTID.TEXT AND CMBATTENDANCE AS GLOBAL N TRIED
CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT)
HOWEVER ITS NOT WORKING...IE..THE COMBO BOX IS NOT FILLED WITH THE ID'S....?
PPLZ HELP ME OUT.....
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Combo Box not populating

 
0
  #2
Sep 20th, 2008
maybe you clear textbox before added id into listbox.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Combo Box not populating

 
0
  #3
Sep 22nd, 2008
Originally Posted by laghaterohan View Post

I TRIED DECLARING THE TXTID.TEXT AND CMBATTENDANCE AS GLOBAL N TRIED
CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT)
I don't know if this is a mistake in your code or if you just copied your code incorrectly to the forum... in the statement CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT), since the combobox is on a different form than TXTID textbox, you need to specify which form the combobox is on (assuming the code is on the form with the textbox).

In other words, if the attendance form is called ATTENDANCE, then the code you specified in your post should be ATTENDANCE.CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT) Again, that is assuming the code is on the form with the TXTID textbox.

Please let us know if this helps!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Re: Combo Box not populating

 
0
  #4
Sep 23rd, 2008
Originally Posted by timothybard View Post
I don't know if this is a mistake in your code or if you just copied your code incorrectly to the forum... in the statement CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT), since the combobox is on a different form than TXTID textbox, you need to specify which form the combobox is on (assuming the code is on the form with the textbox).

In other words, if the attendance form is called ATTENDANCE, then the code you specified in your post should be ATTENDANCE.CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT) Again, that is assuming the code is on the form with the TXTID textbox.

Please let us know if this helps!
sure i will check out if this works...n ll surely let u knw!

thanks
cya
Rohan
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 22
Reputation: isaackhazi is an unknown quantity at this point 
Solved Threads: 0
isaackhazi isaackhazi is offline Offline
Newbie Poster

Re: Combo Box not populating

 
0
  #5
Sep 24th, 2008
Ur Problem is pretty simple. This is what you have to do:

When the ID is entered inot the textbox im assuming that it is saved in ur database in some column.

Your items in the Combobox have to be databound with the column that contains the ID's in the database.

1st: Add a new data source to your project : Data -> add data source
Select the table that contains the ID values and select the column that contains the ID values.
2nd: Once the datasource is created click on your combobox in design mode
(You will see a small white icon in the corner of the Combobox)
click on it and select bind to datasource
3Rd: Select the column that the ID is in and bind it to the combobox

This way all the Ids in the DB table will be displayed in the Combobox and any new added Id's will also be displayed. Cheers. Hope this helped.

Im here if you have anyother questions.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 3
Reputation: jasondemon is an unknown quantity at this point 
Solved Threads: 0
jasondemon jasondemon is offline Offline
Newbie Poster

Re: Combo Box not populating

 
0
  #6
Jul 21st, 2009
Does data have to be databound?

I ask because this won't work and I have no idea why:
Dim str As New StreamReader("C:\Duping\servers.txt")
Dim server As String = str.ReadToEnd().ToString()
str.Close()
Dim thisconnection As New SqlConnection("server=" & server & ";integrated security=True;database=projects")
Dim thisAdapter As New SqlDataAdapter()
Dim cmdthisAdapter As New SqlCommand("SELECT ProjectNumber, ProjectName FROM Projects", thisconnection)
thisAdapter.SelectCommand = cmdthisAdapter
Dim thisdataset As New DataSet()
thisAdapter.Fill(thisdataset, "ProjectNumbers")
For Each therow As DataRow In thisdataset.Tables("ProjectNumbers").Rows
Dim fart As String = therow("ProjectNumber").ToString()
ListBoxPROJECT.Items.Add(fart.ToString())
Next
thisconnection.Close()
I tried adding the string just to see if the data item was there and indeed each "therow" had a valid projectnumber but it just won't go into the listbox (I tried combobox too and that didn't work either)

Any ideas?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC