我的 vb.net 程序中有一个 ultragrid 和一个计时器。每次我的计时器滴答作响时,它都会重置我单击的任何选定行。所以我想在每个刻度上保存行的索引并在刻度后重新加载它。问题是我的网格中也有组。所以我可能有 2 组,每组我可能有 3 行和 5 行。所以我需要知道如何选择组和该组内的行来保存它并在勾选后重新加载它。我知道我选择带有 ultragrid.activeRow 等的行。
这是我的群组
Dim dt As DataTable = Nothing
Timer1.Enabled = True
UltraGrid1.DataSource = Nothing
Generic.openOrders(dt)
UltraGrid1.DataSource = dt
Dim band As Infragistics.Win.UltraWinGrid.UltraGridBand = UltraGrid1.DisplayLayout.Bands(0)
UltraGrid1.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy
band.SortedColumns.Add(band.Columns("ORDERDATE"), False, True)
band.SortedColumns.Add(band.Columns("ORDERTIME"), False, True)
band.Columns("USERNAME").CellClickAction = CellClickAction.RowSelect
band.Columns("QUANTITY").CellClickAction = CellClickAction.RowSelect
band.Columns("ORDERLIST").CellClickAction = CellClickAction.RowSelect
band.Columns("LOCATION").CellClickAction = CellClickAction.RowSelect
band.Columns("PAID").Hidden = True
band.Columns("PROCESSING").Hidden = True
band.Columns("COMPLETED").Hidden = True
band.Columns("ITEMTIME").Hidden = True
band.Columns("ITEMPRICE").Hidden = True
band.Columns("ORDERPRICE").Hidden = True
band.Columns("READYORDER").Hidden = True
UltraGrid1.DisplayLayout.Override.AllowColSizing = Infragistics.Win.UltraWinGrid.ColumnAutoSizeMode.VisibleRows
UltraGrid1.Rows.ExpandAll(True)
我的输出是这样的:
ORDERDATE:
ORDERTIME:
ORDER1 ITEM1
ORDER1 ITEM2
ORDER1 ITEM3
ORDERTIME:
ORDER2 ITEM1
ORDER2 ITEM2
ORDERDATE:
ORDERTIME:
ORDER3 ITEM1
ORDER3 ITEM2
ORDER3 ITEM3
ORDER3 ITEM4
我设法使用以下代码获取了 ORDERDATE、ORDERTIME 和 ORDER 的索引:
If UltraGrid1.Selected.Rows.Count > 0 Then
Dim rowSelected As UltraGridRow
For Each rowSelected In UltraGrid1.Selected.Rows
rowIndex = rowSelected.Index
itemTimeIndex = rowSelected.ParentCollection.ParentRow.Index
orderTimeIndex = rowSelected.ParentCollection.ParentRow.ParentCollection.ParentRow.Index
Next
End If
现在我怎样才能将它们设置回新的超网格?