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
Server SBS 2003 DHCP & DNS issue
New user able to send but not able to receive email
ASP.NET - why would I get this error on my host when I do not get it on my localhost
Auto complete in Outlook 2010
Networking problems windows 7, typing on computer B appears on computer A
How to show Inbox Time column?
How can I prvent to copy if directory is empty when using RichCopy
ActiveSync Mobile Not Working on SBS 2003 Virtualized in ESX 4.0
Set zoom level on a new internet explorer window
IE Home page and Group Policies. Windows server 2008R2