| | |
Combo Box not populating
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
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.....
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.....
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 *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
•
•
I TRIED DECLARING THE TXTID.TEXT AND CMBATTENDANCE AS GLOBAL N TRIED
CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT)
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!
•
•
Join Date: Aug 2008
Posts: 126
Reputation:
Solved Threads: 1
•
•
•
•
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!
thanks
cya
Rohan
•
•
Join Date: Sep 2008
Posts: 22
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Jul 2009
Posts: 3
Reputation:
Solved Threads: 0
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?
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?
![]() |
Similar Threads
- SQL querry Combo Box Question (C#)
- Multi column combo box (VB.NET)
- Problem with Form and Combox selections (C#)
- A couple of things (Visual Basic 4 / 5 / 6)
- VB and Excel. (Visual Basic 4 / 5 / 6)
- VB Combo Population (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Fill textox with mysql data
- Next Thread: Fill DataGrid with SqlServer Table
| Thread Tools | Search this Thread |
.net .net2008 2008 access account advanced application array basic beginner browser button buttons center click code combo cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic excel exists fade filter forms generatetags gridview html images input insert intel internet listview map mobile module monitor msaccess net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey table temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year






