StrataFrame Forum

Reference Columns by name also in the ListView.RowPopulating

http://forum.strataframe.net/Topic23348.aspx

By Edhy Rijo - 6/4/2009

It would be really helpful and safer to be able to reference a column by its name instead of the index in the ListView.RowPopulating event.



Ex Current code:



Private Sub VendorsBrowseDialog_RowPopulating(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) Handles MyBase.RowPopulating

'-- Strong type the passed business object

With CType(e.BusinessObject, CardTrackingSystem.Business.bizVendor)

e.UseGroup = True

e.GroupHeaderText = MicroFour.StrataFrame.Tools.Common.GetEnumDisplayValue(.VendorType)



'-- Show the Inactive Status with a red color

If .IsInactive Then

e.RowForeColor = Drawing.Color.Red

e.Values(4).DisplayValue = "Yes"

Else

e.Values(4).DisplayValue = String.Empty

End If

End With

End Sub







Ex Suggested code:



Private Sub VendorsBrowseDialog_RowPopulating(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) Handles MyBase.RowPopulating

'-- Strong type the passed business object

With CType(e.BusinessObject, CardTrackingSystem.Business.bizVendor)

e.UseGroup = True

e.GroupHeaderText = MicroFour.StrataFrame.Tools.Common.GetEnumDisplayValue(.VendorType)



'-- Show the Inactive Status with a red color

If .IsInactive Then

e.RowForeColor = Drawing.Color.Red

e.Values("VendorIsInactive").DisplayValue = "Yes"

Else

e.Values("VendorIsInactive").DisplayValue = String.Empty

End If

End With

End Sub