Hi, I have built a DataGridView where rows are my resources (carpenters, electricians, welders, ...) and columns are days. Each cell contains the units of the resource avaiable for each day.
Users can choose the first and the last day to be shown in the DG.
For that I use a datatable binded to the DG, adding a column for each day.
I use the code below:
No problems if the time period between firstDay and lastDay is about a week, but if it's more than a month, the While...End While takes long time to end
I see that
is more and more slow at each cycle.
Is there a better way to do what I would do?
Users can choose the first and the last day to be shown in the DG.
For that I use a datatable binded to the DG, adding a column for each day.
I use the code below:
VB.NET:
Dim dt As New DataTable
Dim firstDay As DateTime
Dim lastDay As DateTime
While firstDay <= lastDay
Using col As New DataColumn(firstDay.ToLongDateString, GetType(Int32))
dt.Columns.Add(col)
firstDay = firstDay.AddDays(1)
End Using
End While
For Each res As Resource In MyResourceList
Dim row As DataRow = dt.NewRow
For Each col As DataColumn In dt.Columns
Dim day As DateTime = ... FindColumnDay(col)
row(dt.Columns(col.ColumnName)) = ... res.GetAvailabilityAt(day)
Next
dt.Rows.Add(row)
Next
No problems if the time period between firstDay and lastDay is about a week, but if it's more than a month, the While...End While takes long time to end
I see that
VB.NET:
dt.Columns.Add(col)
Is there a better way to do what I would do?