У меня динамический набор DataGrids показывая очереди (состояния производства элементов), населенный из базы данныхизменение цвета ячейки динамически создается DataGridView
'The datagridviews have already been created at form load.
'get the Qs list - returns datatable with list of queuenames.
Qlist = dbconnect.dbCall("SELECT * FROM QueueList")
For iQlist = 0 To Qlist.Rows.Count - 1
'iterate the queue List and populate the datagridview for showing that queue with any items in that queue
listContents = dbconnect.dbCall("SELECT itemName,queueEntryTime FROM " & Qlist.Rows(iQlist).Item("Q_name"))
'get the dynamic name of the datagridview
Dim controlName = "dg_" & Qlist.Rows(iQlist).Item("Q_name")
'assign the datatable containing its items to that datagridview
Me.tabQsAndServiceBays.Controls.Item(controlName).dataSource = listContents
'want to colour items in each datagrid that are over certain age.
'i.e. the items is in production queue for too long, something has gone wrong.
For Each dr As DataGridViewRow In tabQsAndServiceBays.Controls.Item(controlName).rows
'condition for each row based on cell's contents, if > 20mins mark different color.
If tabQsAndServiceBays.Controls.Item(controlName).Cells("queueEntryTime").Value > Now - 20 Then
dr.DefaultCellStyle.BackColor = Color.LightGreen
End If
'next
Next
я получаю ошибку Public member 'rows' on type 'DataGrid' not found
.
Почему я могу ссылаться на свойство вида datagrid .datasource
, но не .rows
?
Вы совершенно правы. Определение для одного набора datagridviews, я изменился, но я забыл изменить другой. Удивительно, как простая ошибка может привести к часам царапин на голове. Я знал, что изменил его с datagrid на представление datagrid, но не в том месте. Спасибо за помощь! – bendecko