6 Replies - 1002 Views - Last Post: 02 March 2013 - 09:50 AM Rate Topic: -----

#1 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 01-October 12

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.

   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



Is This A Good Question/Topic? 0
  • +

Replies To: Datagridview items not showing in Combobox.

#2 IronRazer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 329
  • View blog
  • Posts: 996
  • Joined: 01-February 13

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)

This post has been edited by IronRazer: 01 March 2013 - 04:20 AM

Was This Post Helpful? 0
  • +
  • -

#3 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 01-October 12

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.
Was This Post Helpful? 0
  • +
  • -

#4 IronRazer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 329
  • View blog
  • Posts: 996
  • Joined: 01-February 13

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

Was This Post Helpful? 0
  • +
  • -

#5 IronRazer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 329
  • View blog
  • Posts: 996
  • Joined: 01-February 13

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


:whistling:
Was This Post Helpful? 0
  • +
  • -

#6 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 01-October 12

Re: Datagridview items not showing in Combobox.

Posted 02 March 2013 - 09:20 AM

Thanks for your reply but that doesn't work.
Was This Post Helpful? 0
  • +
  • -

#7 raelkun00  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 01-October 12

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1