Cognize
asked on
Problem populating DataGridView in VB.NET Forms App
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
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
form.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER