GridView合併儲存格之後,處理「隔行變底色(AlternatingRowStyle)」的問題
http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=2608665&SiteID=14
會把GridView左邊的第一行格子,
若上下格皆有相同的內容,自動變成 "同一格"
就是底下粗體字介紹的, GridView1.Rows(第幾列).Cells(0).RowSpan = 數字,代表上下合併幾格?
請參考
Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender
'==參考資料: http://epaper.blueshop.com.tw/board/show.asp?subcde=BRD20061225110536B4G&fumcde=FUM20050124192253INM
Dim i As Integer = 1
Dim wkItem As GridViewRow
For Each wkItem In GridView1.Rows
If CInt(wkItem.RowIndex) = 0 Then
wkItem.Cells(0).RowSpan = 1
Else
If wkItem.Cells(0).Text.Trim() = GridView1.Rows(CInt(wkItem.RowIndex) - i).Cells(0).Text.Trim() Then
GridView1.Rows(CInt(wkItem.RowIndex) - i).Cells(0).RowSpan += 1
i = i + 1
wkItem.Cells(0).Visible = False
Else
GridView1.Rows(CInt(wkItem.RowIndex)).Cells(0).RowSpan = 1
i = 1
End If
End If
Next
End Sub
留言列表