0

这些属性可以组合成一行vb代码吗?

e.Row.Cells(1).Attributes.Add("id", "MyID")
e.Row.Cells(1).Attributes.Add("class", "MyCLASS")   
4

1 回答 1

0

不使用框架。如果你真的需要做一行,写一个方法......

AddIdAndClassToCell(e.Row.Cells(1), "MyId", "MyClass")

Private Sub AddIdAndClassToCell(cell, id, class)
    cell.Attributes.Add("id", id)
    cell.Attributes.Add("class", class)
End Sub

或者你可以做一个更通用的助手......

Private Sub AddAttributes(cell, attributes As Dictionary(of String, String))
    For Each item As KeyValuePair(Of String, String) In attributes
        cell.Attributes.Add(item.Key, item.Value)
    Next
End Sub
于 2013-04-02T14:29:38.360 回答