Solved

Problem populating DataGridView in VB.NET Forms App

Posted on 2009-07-14
2
519 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 500 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.net/VSTO Excel Add-in 2 38
YouTube API get the Video Tags - vb.net 7 51
Difference between Leaflet and MapBox? 5 45
.NET universe documentation poster 2 22
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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