Adding a Row to an Unbound DataGridView ??
- From: "eBob.com" <eBob.com@xxxxxxxxxxxxxxxx>
- Date: Sat, 5 Jul 2008 22:41:53 -0400
I am using a DataGridView, unbound, for the first time and am unable to add
a row. My add a row code looks like this ...
Sub AddRow(ByRef dirname As String, ByRef filename As String, ByRef length
As Long, _
ByRef lat As Date)
Dim RowData As New CRowData
With RowData
.dirname = dirname
.filename = filename
.length = length
.lat = lat
End With
With Me.DataGridView1
.Rows.Add(RowData)
End With
End Sub 'AddRow
Class CRowData
Public dirname As String
Public filename As String
Public length As Long
Public lat As Date
End Class
A break after setting up RowData for the first row indicates that the right
data is in RowData. But only the first column is populated and it is set,
incorrectly, to "FlatView.Form1+CRowData".
In an earlier version of the code all columns were String and I successfully
used code like this ...
Dim row As String() = {"11/22/1968", "29", "Revolution 9", _
"Beatles", "The Beatles [White Album]"}
With Me.songsDataGridView.Rows
.Add(row)
End With
But then I discovered that my "length" column, as a String, was not sorting
properly. So I've made that column a Long, but now I can't figure out how
to add the row data. I found some doc indicating that Rows.Add() will take
an object but I must not completely understand how to do that.
I'll be grateful for any help. Thanks, Bob
.
- Follow-Ups:
- RE: Adding a Row to an Unbound DataGridView ??
- From: SurturZ
- RE: Adding a Row to an Unbound DataGridView ??
- Prev by Date: Dynamic Toolstrips in VB.net 2005
- Next by Date: RE: Adding a Row to an Unbound DataGridView ??
- Previous by thread: Dynamic Toolstrips in VB.net 2005
- Next by thread: RE: Adding a Row to an Unbound DataGridView ??
- Index(es):
Relevant Pages
|