2013-05-16 4 views
0

나는 foreach를 사용하여 열로 그리드에 루프를 만들고 한 열로 반복하면서 유효성 검사를 수행하고 다음 가시 열로 루프를 반복하여 셀의 이미지를 재설정해야합니다. 란.울트라 그리드의 다음 열로 루프

// 코드

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

       If (col.Hidden = False) Then 

        'Get the first cell of the first column in the grid 
        cell= row.Cells(col.Index) 

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


        'Loop in to the next visible column and reset the image of the cell 
         //Code here 
        cell= row.Cells(UltraGridColumn.Index + 1) 

        'Reset the cell image 
        cell.Appearance.ResetImage() 

        Exit For 
       End If 
      Next 

내가 어떻게 이것을 달성 할 수 있습니까?

+0

클래스의 동일한 이름 (UltraGridColumn, UltraGridRow, UltraGridCell)을 사용하여 이러한 변수를 호출하지 마십시오. 그것은 매우 혼란 스럽습니다. 그리고 실제 코드의 문제점은 무엇입니까? – Steve

+0

잘 작동하지만 두 번째 열에있는 루프가 현재 세 번째 열을 병렬로 반복하여 셀을 재설정해야하는 경우처럼 수정해야합니다. – iamCR

+0

나를 이해시킨다. 모든 행을 반복해야하고 현재 행의 두 번째 열에있는 값이 유효하지 않은 경우 현재 행의 세 번째 열에있는 이미지를 다시 설정해야합니까? – Steve

답변

0

그래서 ActiveRow 당신이

For Each col In Me.TransactionsGrid.ActiveRow.Band.Columns 
    UltraGridCell cell= row.Cells(col) 
    If (col.Hidden = True) Then 
     cell.Appearance.ResetImage(); 
    else    
     cell.Appearance.Image = My.Resources.Tran_comment_161 
     cell.Appearance.ImageHAlign = HAlign.Right 
     cell.Appearance.ImageVAlign = VAlign.Top 
     Exit For 
    End If    
Next 

당신은 또한 standar을 위해를 사용하여 루프를 제어 할 수 있습니다 숨겨져 있지 않은 ActiveRow의 첫 번째 셀에 이미지를 설정합니다이 코드를 업데이트 할 행이됩니다 랬 ... 다음과 인덱서

For x = 0 To Me.TransactionsGrid.ActiveRow.Band.Columns.Count - 1 
    UltraGridColumn col = Me.TransactionsGrid.ActiveRow.Band.Columns(x) 
    UltraGridCell cell= row.Cells(col) 
    If (col.Hidden = True) Then 
     cell.Appearance.ResetImage(); 
    else    
     cell.Appearance.Image = My.Resources.Tran_comment_161 
     cell.Appearance.ImageHAlign = HAlign.Right 
     cell.Appearance.ImageVAlign = VAlign.Top 
     Exit For 
    End If    
Next 

이 두 번째 방법을 사용하면 열 컬렉션의 시작 인덱스를 변경할 수있는 이점이있다 (뭔가 라인 for x = 1 to Me.TransactionsGrid.ActiveRow.Band.Columns.Count - 1)

+0

두 열 모두에서 이미지를 가져옵니다. 하지만 난 눈금의 첫 번째 열에서 필요합니다. – iamCR

+0

사용자가 두 열을 모두 선택하면 첫 번째 열에 바인딩하고 두 번째 열을 제거해야합니다. 현명한 것처럼 보이고 보이지 않게 할 수있는 4 개의 기둥이 있습니다. – iamCR