【问题标题】:Get the column number in Ultragrid获取 Ultragrid 中的列号
【发布时间】:2013-05-16 08:37:25
【问题描述】:

我必须得到网格中的列号。

例如:如果我将Name,Age,Number 作为网格中的三列,并且我给出列的headertext(Age),它应该返回代表的Number(2) Age 是网格的第二列。

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

现在我必须得到不是hidden 的列号。我有专栏的headertext,我需要号码。

我怎样才能做到这一点?

【问题讨论】:

    标签: .net vb.net infragistics ultrawingrid


    【解决方案1】:

    每个 UltraGridColumn 都有一个名为 Index 的属性,它是带区的列集合中列的索引。因此,如果您想使用标题文本搜索列,您可以这样写

    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 的值。向您的问题添加更多信息,这不是您想要的。

    【讨论】:

    • 这就是我想要的。谢谢@史蒂夫
    • 在索引的帮助下,我试图找到单元格必须在其中设置图像。
    • 你能帮我解决这个问题吗@Steve。 stackoverflow.com/questions/16583718/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-16
    • 1970-01-01
    • 2013-05-11
    • 1970-01-01
    相关资源
    最近更新 更多