Search code examples
.netvb.netinfragisticsultrawingrid

Get the first visible column in Ultragrid


I am having number of columns in my ultragrid with userdefined visible and invisible operations. Now i have to check wheather the column is the first column in the grid. since i have some columns which is binded explicitly with the help of index i cant get the column. Always it shows the same column as the First one.

//Code

For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns

   'Get the first cell column in the grid
   UltraGridCell = UltraGridRow.Cells(UltraGridColumn)

   If ('Check Here') Then

      'Set the cell image
      UltraGridCell.Appearance.Image = My.Resources.Tran_comment_161
      UltraGridCell.Appearance.ImageHAlign = HAlign.Right
      UltraGridCell.Appearance.ImageVAlign = VAlign.Top

   Else
      UltraGridCell.Appearance.ResetImage()
   End If
Next

How to achieve this?


Solution

  • With a flag to check which column is selected, this code works fine.

    For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns
    
           'Get the first cell column in the grid
           UltraGridCell = UltraGridRow.Cells(UltraGridColumn)
    
           If ('Check Here') Then
    
              'Set the cell image
              UltraGridCell.Appearance.Image = My.Resources.Tran_comment_161
              UltraGridCell.Appearance.ImageHAlign = HAlign.Right
              UltraGridCell.Appearance.ImageVAlign = VAlign.Top
    
           Else
              UltraGridCell.Appearance.ResetImage()
           End If
        Next 
    
     If (blnFlag) Then
                        Dim i = 0
                        For Each UltraGridColumn In Me.TransactionsGrid.Rows.Band.Columns
    
                            'Get the first cell of the column in the grid
                            UltraGridCell = UltraGridRow.Cells(UltraGridColumn)
    
                            If (UltraGridColumn.Hidden = False And i = 0) Then
    
                                'Set the cell image
                                UltraGridCell.Appearance.Image = My.Resources.Tran_comment_161
                                UltraGridCell.Appearance.ImageHAlign = HAlign.Right
                                UltraGridCell.Appearance.ImageVAlign = VAlign.Top
                                i += 1
                            Else
                                'Reset the image if other column
                                UltraGridCell.Appearance.ResetImage()
                            End If
    
                        Next
      End If