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
hat is the best way or best practice to give acces to a mailbox for users in Exchange 2003?
simple json example not working
generate guid c# and populate a textbox
Security Book Review
importing & exporting favourites from vista to xp laptops
Run-time error '6' Overflow
Can't edit view in sql
textboxes
How can i use a subquery within a SELECT?
silence Internet explorer