Microsoft
Software
Hardware
Network
Question : How do I add rows to a datagridview based upon a For Each statement in VS2008?
I am trying to create a datagridview that populates a column with a list of plants and then calculate the number of blooms each plant had for each year that the plant was tracked. This is what is working so far:
Dim records = (From id In d.tblSurveys _
Group By TagNo = id.FinalTag Into Group _
Order By TagNo Ascending _
Select TagNo).ToList
Dim recCount = records.Count
If recCount <= 0 Then
MsgBox("No Data Available.", MsgBoxStyle.Information, "Data Request")
Else
Dim dtable As New DataTable
dtable.Columns.Add("FinalT
ag", GetType(Decimal))
'add the years to the table
For Each y In Me.lbYear.DataSource
dtable.Columns.Add(y, GetType(String))
Next
For Each col In dtable.Columns
Dim dc As New DataGridViewColumn
DGridAllYears.Columns.Add(
dc)
dc.HeaderText = col.ToString
Next
Now I am trying to add rows using the records to this datagridview.
I am able to add the plant list to a datatable and display it through a different datagridview.
For Each rec In records
Dim datarow As DataRow = dtable.NewRow
datarow.Item(0) = rec.Value
dtable.Rows.Add(datarow)
Next
But I can't seem to convert this method to a datagridview...
Any help or suggestions would be appreciated!
Thanks.
Answer : How do I add rows to a datagridview based upon a For Each statement in VS2008?
You might have two different types of line breaks.
Try this
Sub zap()
ActiveSheet.[A:A].Replace Chr(13) & Chr(10), " "
ActiveSheet.[A:A].Replace Chr(10), " "
ActiveSheet.[A:A].Replace Chr(13), " "
End Sub
Random Solutions
How can I tell what label template was used on an existing Word file?
Crystal Report Viewer - Export to/open a PDF after entering parameters
sql isnull
How to diagnose long logoff times?
How do I create a looping to add values in columns?
.navigate more than one website in only one IE.7 microsoft windows in VBA Excel
Linux - auto log in to web site
SQL insert not working
Changing Background colors for a column based on contents of cell
IIS 6 MIME type for .prd