2012-07-19 2 views
0

gridview에있는 'LeadTime'의 가장 높은 값을 빨간색으로 설정하고 싶습니다.gridview에서 가장 높은 값을 얻기 위해 텍스트의 색상을 빨간색으로 설정하는 방법은 무엇입니까?

If e.Row.RowType = DataControlRowType.DataRow Then 
      Dim LeadTime As Integer = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "LeadTime")) 
      If LeadTime > 0 Then 
       e.Row.ForeColor = System.Drawing.Color.Blue 
     End If 
End If 
+1

DataGridView.CellFormatting 이벤트 사용 – SSS

답변

0

이렇게하는 방법에는 여러 가지가 있습니다. 가장 간단한 것 (나는 생각한다) 인덱스 최대 (LeadTime) 행을 얻는 것입니다.

당신은 같은 리드 타임의 최대 값 찾기 위해 그리드보기의 모든 행을 반복하는 데 필요한 모든의
gridView1.Rows(obtainedRowIndex).ForeColor=System.Drawing.Color.Blue 
+0

중복되는 경우에도 leadtime의 가장 높은 값에 대한 gridview의 텍스트 색을 변경하고 싶습니다. –

1

첫째 : 지금 당신은 다음과 같은 사용하여 해당 행의 forcolor을 설정할 수 있습니다

int maxLeadTime=0; 
int maxRowIndex=0; 
for(int i=0;i<yourGv.Rows.Count;i++) 
{ 
    int currentLeadTime =Convert.ToInt32(yourGv.Rows[i].FindControl("idOfControlStoresLeadTime").ToString()); 
    if(maxLeadTime<currentLeadTime) 
    { 
     maxLeadTime=currentLeadTime; 
     maxRowIndex=i; 
    } 
} 

를 :

yourGv.Rows[maxRowIndex].ForeColor = System.Drawing.Color.Red; 

위의 솔루션은 리드 타임의 가장 높은 값의 앞 색상을 빨간색으로 설정합니다.

관련 문제