locked
How to call out a form2 with database/dataset when i press a button in form 1

    Question

  • just as what i mentioned in above, the problem is i add a new windows form, in which is a database with dataset, in the main form when i press a button. this database form should come out, i used the easiest way like  form2.show(), while conforms wrong, so is there any solution to this???

    Thanks! i'm rushing it!

    Monday, September 19, 2011 3:40 AM

Answers

  • Hello techprogramming,

    just as what i mentioned in above, the problem is i add a new windows form, in which is a database with dataset, in the main form when i press a button. this database form should come out, i used the easiest way like  form2.show(), while conforms wrong, so is there any solution to this???

    Thanks! i'm rushing it!

    not very clear what you ask, but according to what I understand you can not see the push of a button the form2 to form1, and the syntax looks like this.

     

      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim fr2 As New Form2
            fr2.Show()
        End Sub
    
    or open the form as a modal form 2.
    
      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim fr2 As New Form2
            fr2.ShowDialog()
        End Sub

     

    Regards.
    Carmelo La Monica

    Blog http://community.visual-basic.it/carmelolamonica/

    WordPress http://carmelolamonica.wordpress.com/

    Twitter  http://twitter.com/carmelolamonica

    Monday, September 19, 2011 5:57 AM
  • Hi TechProgramming,

    Welcome to the MSDN Forum.

    Please take a look at Carmelo's suggestion. It should be helpful.

    In addition, you can put the load data code in the load event handler of form2.

    For example:

    private sub form2_load(......) handle form2.load

    query the database and pur the result in a datatable

    me.datagridview.datasource = the datatable

    End sub

    So when form2 show, you can see the data from the database in the datagridview.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, September 21, 2011 9:57 AM
    Moderator

All replies

  • Hi,

    Could you elaborate your scenario, with an example?. so that i can help.

    Regards,

    A.Murugan.

     


    If it solved your problem,Please click "Mark As Answer" on that post and "Mark as Helpful". Happy Programming!
    Monday, September 19, 2011 5:33 AM
  • Hello techprogramming,

    just as what i mentioned in above, the problem is i add a new windows form, in which is a database with dataset, in the main form when i press a button. this database form should come out, i used the easiest way like  form2.show(), while conforms wrong, so is there any solution to this???

    Thanks! i'm rushing it!

    not very clear what you ask, but according to what I understand you can not see the push of a button the form2 to form1, and the syntax looks like this.

     

      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim fr2 As New Form2
            fr2.Show()
        End Sub
    
    or open the form as a modal form 2.
    
      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim fr2 As New Form2
            fr2.ShowDialog()
        End Sub

     

    Regards.
    Carmelo La Monica

    Blog http://community.visual-basic.it/carmelolamonica/

    WordPress http://carmelolamonica.wordpress.com/

    Twitter  http://twitter.com/carmelolamonica

    Monday, September 19, 2011 5:57 AM
  • Your question is not clear showing form is not a difficult task. Please tell what action do you want to perform while showing the form.

    *If you problem has been solved then please mark this post as answered.

    Wednesday, September 21, 2011 7:12 AM
  • Hi TechProgramming,

    Welcome to the MSDN Forum.

    Please take a look at Carmelo's suggestion. It should be helpful.

    In addition, you can put the load data code in the load event handler of form2.

    For example:

    private sub form2_load(......) handle form2.load

    query the database and pur the result in a datatable

    me.datagridview.datasource = the datatable

    End sub

    So when form2 show, you can see the data from the database in the datagridview.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, September 21, 2011 9:57 AM
    Moderator
  • It do works already if i do seperately in another project. use the form2.show()

    while apply it in XBee project, same way always said wrongly, So now i checked whether got another way to solve it.

    But Thanks all the time!

    Thursday, September 22, 2011 8:26 AM
  • Hi TechProgramming,

    OK, it is fine. If you have found another solution, please share it here, it will be benifit with the other community members which have the similar questions.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, September 22, 2011 8:33 AM
    Moderator