none
Datagridview RRS feed

  • Question

  • Hello,

    I have taken your advice in a previous question and moved to Datagridview. In my project there are two forms using Datagridview, one is linked to a database and the other not. I have successfully converted the one not linked to a database, but are struggling with the one linked to a database.

    I have read the documentation you kindly pointed me towards and they all assume that you will put the datagrid on to the form programmatically. In my case I have put the datagtrid on using the form designer, which is straight forward enough. The form simply displays one table from an Access database.

    The problem I have is when the program runs and the form is displayed, no data is displayed. Please would someone point me to what I need to do.

    Thanks for reading

    Sunday, April 15, 2018 11:27 PM

Answers

  • Hi Cherry,

    Thanks for the links.  In my case I am trying to display one table in its entirety on a form. All the examples given assume that the grid is going to put on the form using code. There do not seem to be any examples/help given to using the form design tools.

    It would be nice to find them somewhere. 

    I my case I have managed somehow to get the form to work, linking to the database in another directory. One moment it didn't work, then it did. I don't know what I did to get it to work.

    Hi Denis,

    You means that you have done it now? You mean that you want to use an Entity Framework Entity as a Windows Forms Data Source? If yes, you can take a look this article---Bind object to control

    https://msdn.microsoft.com/en-us/library/jj682076(v=vs.113).aspx

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Denis Oxon Wednesday, April 25, 2018 1:03 PM
    Wednesday, April 25, 2018 6:12 AM
    Moderator

All replies

  • Hello,

    In regards to "I have taken your advice", who are you referring too?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, April 16, 2018 12:10 AM
    Moderator
  • Have you specified a data source for the datagridview? Or how does the data get to the dgv? Give more details of what you are doing and what the problem is.

    ie

       Dim dt As New DataTable("Sample")
    
       'fill dt somehow
    
    
       DataGridView1.DataSource = dt
    

    Monday, April 16, 2018 12:41 AM
  • What does converted one not linked to a database mean. And if the other is successfully linked to a database why does no data display?

    La vida loca

    Monday, April 16, 2018 1:10 AM
  • Thank you all for taking an interest. Sorry that my original question was somewhat jumbled. I have now succeeded in getting the data to be displayed.

    However I can not find a way of connecting to a database that is in a different directory from the program. Any one point me in the right direction please ?

    Wednesday, April 18, 2018 10:18 PM
  • Thank you all for taking an interest. Sorry that my original question was somewhat jumbled. I have now succeeded in getting the data to be displayed.

    However I can not find a way of connecting to a database that is in a different directory from the program. Any one point me in the right direction please ?

    Hi Denis,

    Do you want to know how to connect ms DataBase and load data into DatagridView directly, If yes, please take a look the simple sample:

    http://www.visual-basic-tutorials.com/DisplayToAccess.htm

    Here is the example that Karen writing:

    https://code.msdn.microsoft.com/Working-with-data-in-a-e24664d9?redir=0

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 24, 2018 6:34 AM
    Moderator
  • Hi Cherry,

    Thanks for the links.  In my case I am trying to display one table in its entirety on a form. All the examples given assume that the grid is going to put on the form using code. There do not seem to be any examples/help given to using the form design tools.

    It would be nice to find them somewhere. 

    I my case I have managed somehow to get the form to work, linking to the database in another directory. One moment it didn't work, then it did. I don't know what I did to get it to work.

    Tuesday, April 24, 2018 8:17 PM
  • Hi Cherry,

    Thanks for the links.  In my case I am trying to display one table in its entirety on a form. All the examples given assume that the grid is going to put on the form using code. There do not seem to be any examples/help given to using the form design tools.

    It would be nice to find them somewhere. 

    I my case I have managed somehow to get the form to work, linking to the database in another directory. One moment it didn't work, then it did. I don't know what I did to get it to work.

    Hi Denis,

    You means that you have done it now? You mean that you want to use an Entity Framework Entity as a Windows Forms Data Source? If yes, you can take a look this article---Bind object to control

    https://msdn.microsoft.com/en-us/library/jj682076(v=vs.113).aspx

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Denis Oxon Wednesday, April 25, 2018 1:03 PM
    Wednesday, April 25, 2018 6:12 AM
    Moderator