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
INDEX/MATCH formula that will identify multiple matches
Sort elements after explode in php
Updating VMWare tools for guest OS on ESX 4.0 and ESXi host?
Server 2008 will restart on its own with this error during DC promo to this server
How to dump one MySQL record to put in another database?
Quick Excel Question
CISCO ASA 5505 blocking internet access on specific mac address on local network
Block E-mail Address with Jquery
FTP from a UNIX server to a Windows platform
Track which PC is spamming domino smtp