Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem populating DataGridView in VB.NET Forms App

Posted on 2009-07-14
2
Medium Priority
?
522 Views
Last Modified: 2013-11-07
Hi,

I'm having trouble getting a DataGridView to populate in this simple VB.NET forms application.

I'm going through, creating the dataset, adding columns and then rows, but when I run the program, no exceptions are thrown, but my datagrid view is completely empty.

Can anyone suggest what might be wrong here?

Cheers
Imports ToDoListLibrary
Imports System.IO
Imports System.Data.SqlClient
 
 
Public Class ToDoListUI
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        Dim toDoItem = New ToDoItem()
 
        toDoItem.ToDoItemDoneProperty() = False
        toDoItem.ToDoItemDoneDateTimeProperty() = DateTime.Now
        toDoItem.ToDoItemDoByDateTimeProperty() = DateTime.Now
        toDoItem.ToDoItemTextProperty() = ""
        toDoItem.ToDoItemPriorityProperty() = toDoItem.ToDoItemPriorityProperty().High
 
        Dim toDoList = New ToDoList()
 
        toDoList.ToDoItemListProperty().Add(toDoItem)
 
 
        Dim ds As DataSet = New DataSet()
 
        Dim tb As DataTable = ds.Tables.Add()
 
        tb.Columns.Add("ToDoItemDone", GetType(Boolean))
        tb.Columns.Add("ToDoItemDoneDateTime", GetType(DateTime))
        tb.Columns.Add("ToDoItemDoByDateTime", GetType(DateTime))
        tb.Columns.Add("ToDoItemText", GetType(String))
        tb.Columns.Add("ToDoItemPriority", GetType(ToDoItem.ToDoItemPriority))
 
 
        For Each toDo As ToDoItem In toDoList.ToDoItemListProperty()
 
            tb.Rows.Add(toDo.ToDoItemDoneProperty, toDo.ToDoItemDoneDateTimeProperty, _
                         toDo.ToDoItemDoByDateTimeProperty, toDo.ToDoItemTextProperty, _
                         toDo.ToDoItemPriorityProperty)
        Next
 
        m_toDoListUIDataGridView.DataSource = ds.DefaultViewManager
 
    End Sub
 
 
End Class

Open in new window

form.JPG
0
Comment
Question by:Cognize
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
RSBuTCHeR earned 2000 total points
ID: 24847770
Hi Cognize,

Try to use this line:

m_toDoListUIDataGridView.DataSource = ds.Tables(0)

or

m_toDoListUIDataGridView.DataSource = dt

Regards,

Falcko
0
 
LVL 2

Author Closing Comment

by:Cognize
ID: 31603175
Thanks mate, thats what I needed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question