Private Sub frmUpdateStudent_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To frmRecords.DataGridView1.Rows.Count - 2
ComboBox1.Items.Add(frmRecords.DataGridView1.Rows(i).Cells(0).Value)
Next
End Sub
Datagridview items not showing in Combobox.
Page 1 of 16 Replies - 2355 Views - Last Post: 02 March 2013 - 09:50 AM
#1
Datagridview items not showing in Combobox.
Posted 28 February 2013 - 09:56 PM
If I put the code on the same form I have the Datagridview it is working. But if the put it on another form Datagridview items is now working.
Replies To: Datagridview items not showing in Combobox.
#2
Re: Datagridview items not showing in Combobox.
Posted 01 March 2013 - 04:15 AM
Hi raelkun00,
You could try putting the name of your form in front of the datagridview. Like (Form2.nameof datagridview)
You could try putting the name of your form in front of the datagridview. Like (Form2.nameof datagridview)
This post has been edited by IronRazer: 01 March 2013 - 04:20 AM
#3
Re: Datagridview items not showing in Combobox.
Posted 02 March 2013 - 07:59 AM
I already did that but it didnt work. The datagridview is on form-frmRecords and the combobox is on another form which is frmUpdateStudent. What I want is to load the first column of Datagridview to Combobox.
#4
Re: Datagridview items not showing in Combobox.
Posted 02 March 2013 - 08:53 AM
Ok i think i get it now. (frmRecords) is the main form and when it loads you want to send the text from its DataGridView1 to Combobox1 on the secondary form (frmUpdateStudent). If that is correct did you try it this way? The code has to be on (frmRecords) form.
frmUpdateStudent.ComboBox1.Items.Add(DataGridView1.Rows(i).Cells(0).Value)
This post has been edited by IronRazer: 02 March 2013 - 08:57 AM
#5
Re: Datagridview items not showing in Combobox.
Posted 02 March 2013 - 09:12 AM
Sorry, i guess i didn`t get it untill i looked again. If you use this in the (frmRecords) form in the event that opens (frmUpdateStudent) it should work. Make sure you are showing frmUpdateStudent with "frmUpdateStudent.Show()" and not with "frmUpdateStudent.ShowDialog()" or it will not work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
frmUpdateStudent.Show()
For i As Integer = 0 To DataGridView1.Rows.Count - 2
frmUpdateStudent.ComboBox1.Items.Add(DataGridView1.Rows(i).Cells(0).Value)
Next
End Sub
#6
Re: Datagridview items not showing in Combobox.
Posted 02 March 2013 - 09:20 AM
Thanks for your reply but that doesn't work.
#7
Re: Datagridview items not showing in Combobox.
Posted 02 March 2013 - 09:50 AM
Oh I am sorry that works but my problem is frmRecords is an MDIChild of frmMainForm. In frmMainForm there's a button that when clicked it will load the frmUpdateStudent.Thank you so much.
Page 1 of 1

New Topic/Question
Reply


MultiQuote



|