StrataFrame Forum

How to enter a Blank date ito a SF DateBox

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

By Ger Cannoll - 5/17/2012

I am using the SF dateBox to store dates, and BO is set not to accept nulls, so a Blank is added in as 01/01/1800, and displays as a blank

User then selects a date, say today, and it displays as : 17-05-2012   all fine so far

User then realises he really does not want a date in the DateBox  (i.e. wants a Blank date) 

The only way I can see of doing this is for the user to type in 01/01/1800, which unless the user knew that this date meant 'Blank', he would have no way of changing the date to blank

Is there any way of blanking out the Date (by hitting the space bar or similar)  other than having to type in a date of 01-01-1800

I have a lot of forms where , depending on some other controls on the form, the date may or may not be mandatory, so I am looking for an 'intuitive' way of blanking out the date if a date has already been entered into the control
By Ivan George Borges - 5/17/2012

Hi Ger.

The F6 function key will erase the DateBox contents.
I have inherited the DataBox into my own DateBox and added some functionality, one of them being the ability to use the Del key to perform this same action.

Here is the code if you decide to go for it:

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        Select Case keyData
            Case Keys.Delete
                '-- Delete key pressed, send an F6 to clear contents
                Return MyBase.ProcessCmdKey(msg, Keys.F6)
        End Select

        Try
            Return MyBase.ProcessCmdKey(msg, keyData)
        Catch ex As Exception
            '-- the DateBox will throw an exception if user use keys to add or subtract beyond the bounderies
            '   so in these cases we will just send Home key
            Return MyBase.ProcessCmdKey(msg, Keys.Home)
        End Try
    End Function


Hope it helps.
By Ger Cannoll - 5/18/2012

Hi Ivan. Thnaks for replying.

The F6 will come in very handy and I'll have  a go at copying your Subclass to C#

Regards,

Gerard
By Ivan George Borges - 5/18/2012

You're welcome, Ger. Cool