StrataFrame Forum

Null dates in listview

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

By Lesscher - 9/5/2008

Hi,



More questions about null values... Smile



I use a datepicker to display a date. I have to use the replacement value trick (1800-1-1) in order to save a NULL value when there is no date. No problems here...



How can I show this field in a listview without showing the value 1800-1-1 to the user?



Regards,



Lesscher
By Edhy Rijo - 9/5/2008

Hi Lesscher,

You can use the ListView.RowPopulating event to handle that situation and many more...

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

     '-- Cast the BO to the type needed.

     Using bo As bizItems = DirectCast(e.BusinessObject, bizItems)

          If bo.MyDateTimeField = Nothing orElse bo.MyDateTimeField = #1800-1-1# then

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

          End If

          End Using

End Sub

I have not tested the above, but that can give you an idea.

By William John Tello - 9/9/2008

Edyhy,

Out of curiosity, why would you assign the displayvalue property to String.Empty as opposed to "" (which is what I would have done and I think a more C# standard way to do it).  I'm just curious if there is an advantage to using the Empty static method of the .Net string class?

I'm also assuming there the C# string type must also have a string.Empty() counterpart (which I might have favored because I tend to use the C# types over the .Net types in my own coding).

By Edhy Rijo - 9/9/2008

William John Tello (09/09/2008)
Out of curiosity, why would you assign the displayvalue property to String.Empty as opposed to ""

Hi William,

It is just for readability of the code, I rather see String.Empty than '' or "", in VFP you could use '', "", [] Tongue