.net 获取Ultragrid中的列号

.net 获取Ultragrid中的列号,.net,vb.net,infragistics,ultrawingrid,.net,Vb.net,Infragistics,Ultrawingrid,我必须得到网格中的列号 For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns If (UltraGridColumn.Hidden = False) Then 'UltraGridColumn.Header.Caption 'Get the cell UltraGridCell = UltraGridRow.Cells("Number Here") En

我必须得到网格中的列号

For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns
    If (UltraGridColumn.Hidden = False) Then
        'UltraGridColumn.Header.Caption
        'Get the cell
         UltraGridCell = UltraGridRow.Cells("Number Here")
    End If
Next
例如:如果我有
姓名
年龄
编号
作为网格中的三列,并且我给出了该列的
标题文本
(年龄),它应该返回表示
年龄的
编号
(2),它是网格的第二列

For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns
    If (UltraGridColumn.Hidden = False) Then
        'UltraGridColumn.Header.Caption
        'Get the cell
         UltraGridCell = UltraGridRow.Cells("Number Here")
    End If
Next
现在我必须得到列号,它不是
隐藏的
。我有该列的
标题文本
,我需要号码


如何实现这一点?

每个UltraGridColumn都有一个名为Index的属性,该属性是band列集合中列的索引。因此,如果您想使用标题文本搜索列,可以编写以下代码

For Each col In Me.TransactionsGrid.Rows.Band.Columns
     If (col.Hidden = False) Then
         if col.Header.Caption = searchedHeaderText Then
              grid.ActiveRow.Cells(col).Value = col.Index.ToString()
         End If
     End If
Next

您真正想对索引信息做些什么在您的问题中不是很清楚,因此我使用此信息设置单元格中与搜索列对应的ActiveRow的值。在你的问题中添加更多信息,这不是你想要的。

这是我想要的。谢谢@Steven在索引的帮助下,我正在尝试查找单元格,必须在单元格内设置一个图像。你能帮我回答这个问题吗@Steve。